Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: #242 exported worklet functions are undefined #247

Merged
merged 1 commit into from
Jul 23, 2024

Conversation

hannojg
Copy link
Member

@hannojg hannojg commented Jul 23, 2024

Fixes: #242

The problem is with the reanimated/worklets babel plugin, and has been reported here:

The babel plugin that transpiles our typescript code transforms the typescript to this commonjs code:

Typescript CommonJS
Screenshot 2024-07-23 at 11 31 24 Screenshot 2024-07-23 at 11 31 09

As it can be seen the exports / usage of the variable happens before the function is declared, which causes the worklet function to be undefined (as reported in the REA issue above).

Solution

I checked out rnskia is doing it, and they use const and anonymous functions, which is indeed working as the export then happens after the declaration:

Screenshot 2024-07-23 at 11 30 54

So from now on we must export all worklet functions as const arrow functions

Alternative solutions

I tried to do it as reanimated and remove the CommonJS support, and only create a ES module. However, that didn't work due to some react native bugs, where it can't find the codegen component anymore.

@hannojg hannojg merged commit ee2b4ef into main Jul 23, 2024
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.

changing any model prop value throws uncaught Error helper.isWorkletSahredValue is not a function
1 participant