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

Enable support for Reanimated on the web without a Babel plugin #1740

Closed
joshsmith opened this issue Feb 15, 2024 · 0 comments
Closed

Enable support for Reanimated on the web without a Babel plugin #1740

joshsmith opened this issue Feb 15, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request v5

Comments

@joshsmith
Copy link
Contributor

Feature Request

Enabling support on the web for Reanimated without using a Babel plugin could help users who are using SWC (or other tooling) but would like to use this library.

I am going to need to patch this package regardless, so I would be happy to do a PR and get this into 5.0.0 (I'm on an alpha branch as it is).

Why it is needed

In order to use Reanimated without a Babel/SWC plugin, you need to explicitly pass the dependency array whenever you use a Reanimated hook.

Possible implementation

We would need to add dependency arrays to anywhere in the codebase where they don't exist to these hooks:

  • useDerivedValue
  • useAnimatedStyle
  • useAnimatedProps
  • useAnimatedReaction

Passing a dependency array is valid on both Web and native. Adding them will not negatively impact iOS or Android.

Code sample

const sv = useSharedValue(0);
const dv = useDerivedValue(
  () => sv.value + 1,
  [sv] // dependency array here
);
@joshsmith joshsmith added the enhancement New feature or request label Feb 15, 2024
@gorhom gorhom self-assigned this Feb 18, 2024
@gorhom gorhom added the v5 label Feb 18, 2024
@gorhom gorhom closed this as completed Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request v5
Projects
None yet
Development

No branches or pull requests

2 participants