Skip to content

fix(web): create custom hook for useRef logic#666

Merged
kacperzolkiewski merged 1 commit into
mainfrom
@kacperzolkiewski/fix-use-ref
Jul 3, 2026
Merged

fix(web): create custom hook for useRef logic#666
kacperzolkiewski merged 1 commit into
mainfrom
@kacperzolkiewski/fix-use-ref

Conversation

@kacperzolkiewski

Copy link
Copy Markdown
Collaborator

Summary

This PR removes duplicated useRef logic inside EnrichedTextInput by extracting it into a custom useStableRef hook.

Test Plan

Run the example web app and verify that all enriched editor functionalities work properly.

Screenshots / Videos

n/a

Compatibility

OS Implemented
iOS
Android
Web

Checklist

  • E2E tests are passing
  • Required E2E tests have been added (if applicable)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extracts repeated “latest value in a ref” patterns from EnrichedTextInput into a shared useStableRef hook for the web implementation.

Changes:

  • Added a reusable useStableRef hook that keeps a ref’s .current synchronized with the latest value via an effect.
  • Replaced multiple useRef + useEffect blocks in EnrichedTextInput with useStableRef.
  • Adjusted memo/effect dependency lists where the new refs are referenced.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/web/useStableRef.ts Introduces the new hook used to keep “latest” values in refs.
src/web/EnrichedTextInput.tsx Refactors duplicated ref-update logic to use useStableRef for several props/callbacks.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/web/useStableRef.ts
@kacperzolkiewski kacperzolkiewski marked this pull request as ready for review June 30, 2026 12:43

@hejsztynx hejsztynx left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@kacperzolkiewski kacperzolkiewski merged commit d4ee950 into main Jul 3, 2026
8 checks passed
@kacperzolkiewski kacperzolkiewski deleted the @kacperzolkiewski/fix-use-ref branch July 3, 2026 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants