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

chore: Add React 19 support #7055

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

patrycjakalinska
Copy link
Contributor

@patrycjakalinska patrycjakalinska commented Feb 19, 2025

Summary

This PR bumps React to 19 for Reanimated4, and make necessary changes according to React release notes.

Most importantly:

  • function components no longer need forwardRef, we can now access ref as a prop
  • useRef need an initial argument - mostly we used null
  • we can render as a provider instead of <Context.Provider>

Test plan

It'll be tested thoroughly in #7065 as it add RN 0.78 and has diverged from this branch. After #7065 is merged, the best way to test it is to launch Reanimated app on fabric (ios, android) and web and check if it works.

@patrycjakalinska patrycjakalinska changed the title draft: prepare for react 19 chore: bump to React 19 Feb 21, 2025
@patrycjakalinska patrycjakalinska changed the title chore: bump to React 19 chore: Add React 19 support Feb 21, 2025
@@ -44,7 +44,7 @@ function createAnimatedComponent<P extends object>(

#### `component`

The component you want to make animatable. Function components have to be wrapped with `React.forwardRef()`.
The component you want to make animatable.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's ship the docs in a separate PR after we release this change.

Also we should probably mark it that you need forwardRef for reanimated >3.17

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes! Was think about it

@@ -113,13 +113,13 @@ const FlatListForwardRefRender = function <Item = any>(
);
};

export const ReanimatedFlatList = forwardRef(FlatListForwardRefRender) as <
export const ReanimatedFlatList = FlatListRender as <
Copy link
Collaborator

Choose a reason for hiding this comment

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

If I understand correctly, we can't yet commit these changes, since React 19 is only available in React Native 0.78. We have to keep backwards compatibility (at the moment) for at least React Native 0.76, which still has React 18.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I talked with @piaskowyk to release this full React 19 support to Reanimated 4, and React 19 support with backward compatibility for 3.17.x, so user could use either 0.78 or for example 0.77, 0.76 with no problem - i'm currently working on it
It'll be similiar to this but without removing forwardRef and .Provider (only change from React 19 is the useRef() will have initial value). Further changes probably will include guard that would check if is React 19, similiary as GH did it.

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.

2 participants