Skip to content

chore: useHandler reimplementation#9090

Draft
MatiPl01 wants to merge 4 commits intomainfrom
@matipl01/useHandler-reimplementation
Draft

chore: useHandler reimplementation#9090
MatiPl01 wants to merge 4 commits intomainfrom
@matipl01/useHandler-reimplementation

Conversation

@MatiPl01
Copy link
Member

Summary

This PR is a complete reimplementation of the useHandler hook. We experienced multiple issues with the useHandler hook over time and it's about time to reimplement this problematic hook.

The implementation follows requirements specified in the following design doc (crated by @tjzel and @MatiPl01).

1. To remove
   1. useWeb

2. TDD:
   1. whether context works (different handlers should share it)
   2. in which situations `doDependenciesDiffer` can be `false`
      - when the reference to the `handlers` object changes, but the handlers are the same (not the reference, but the implementation)
      - if the reference to handlers changes, it does not mean that `doDependenciesDiffer` must be `true`
   3. when `doDependenciesDiffer` is not necessarily `false` (even though handlers are the same)
      - if worklet hashes are the same
      - if references to closure are different
      - if references to objects in closure are different* (to consider – it is possible that this means the closures are different)
   4. when it definitely changes (`doDependenciesDiffer` is `true`)
      - when keys in the `handlers` object change
      - when handler worklet hashes change
      - when keys in the closures of handlers with the same hash change

3. WEB
   1. When we have a Babel plugin
      - we assume behavior the same as natively (handlers are exclusively worklets, we do not pass dependencies)
   2. When there is no Babel plugin
      - if there are dependencies
         - we only compare dependencies (shallow) like in React hooks
      - if there are no dependencies
         - empty array
            - `doDependenciesDiffer` is always `false`
         - `undefined`
            - `doDependenciesDiffer` is always `true` (like React hooks)

   CONCLUSION: we ignore `handlers` when determining `doDependenciesDiffer`

Test plan

Go through all handler-related examples in the native and web app (on the web, run with (yarn start) and without (yarn start:noplugin) babel plugin).

image

@MatiPl01 MatiPl01 self-assigned this Mar 12, 2026
@MatiPl01 MatiPl01 requested a review from tjzel March 12, 2026 02:27
@MatiPl01 MatiPl01 marked this pull request as draft March 12, 2026 02:32
@MatiPl01 MatiPl01 linked an issue Mar 12, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

useHandler issues

1 participant