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

RFC: React 19 support #1593

Open
mdjastrzebski opened this issue Apr 26, 2024 · 6 comments
Open

RFC: React 19 support #1593

mdjastrzebski opened this issue Apr 26, 2024 · 6 comments

Comments

@mdjastrzebski
Copy link
Member

mdjastrzebski commented Apr 26, 2024

React team recently released React 19 beta which brings some changes that might affect RNTL. In this issue I want to discuss how does that affect RNTL.

Deprecation of React Test Render

The upgrade guide mentions deprecation of React Test Renderer. First of all this is deprecation, not removal, so our core dependency will continue to work so some time. Callstack be working with Meta to find suitable solution to that case. It's worth noting that RNTL is indicated as recommended testing solution for React Native in the same migration guide.

React 18.3.x

React team released also React 18.3 which should trigger warnings for features being deprecated/removed by React 19. I've run RNTL testing suite, and all test pass without warning.

Versioning strategy

Since RNTL API is relatively mature, and we currently do not plan to release any large new features, I think that we should keep RNTL v12 for React 18 (and earlier) support, while making RNTL v13 with support just for React 19. By doing so, we could remove legacy code supporting React 16, 17 & 18 and focus on just React 19.

We should introduce versioned documentation to allow users of both React 18 and 19 to find relevant info. Otherwise, the API surface will probably stay the same and changes be mostly internal.

Transition timeline

The blog posts does not mention any timeline for React 19 transition for React Native. It is however safe to assume that such transition will happen at some stage around or after React 19 stable release.

@thymikee @pierrezimmermannbam @MattAgn @AugustinLF wdyt?

@thymikee
Copy link
Member

Let's open the v13 branch and start working there :)

@pierrezimmermannbam
Copy link
Collaborator

That sounds like a good plan! Do you know more about RTR's deprecation? Is there already an alternative to react test renderer? If not do we have any idea of when one will be available?

If I understand correctly, based on the tests you did with react 18.3 we're not using that will be removed or deprecated but this does not guarantee that everything will still work. I suppose we'd need a version of react native compatible with react 19 to do more tests?

@mdjastrzebski
Copy link
Member Author

React 18.3 seems to be the same as 18.2 + warnings about stuff removed/deprecated in React 19. You are absolutely right that we will need a matching RN version, I suspect that there will be alpha/beta/RC versions before the actual release.

Regarding RTR replacement, there is not concrete info yet.

@MattAgn
Copy link
Collaborator

MattAgn commented Apr 30, 2024

The plan sounds great!

@yungsters
Copy link

I was about to open a separate issue for this, but I found this one. I hope it's okay to report this here.

At least one breaking change in React 19 seems to be that react-test-renderer/shallow will throw: https://github.com/facebook/react/blame/main/packages/react-test-renderer/npm/shallow.js (cc @jackpope)

I noticed that @testing-library/react-native seems to reference react-test-renderer/shallow here: https://github.com/callstack/react-native-testing-library/blob/main/src/shallow.ts#L3

This module should either begin importing from react-shallow-renderer directly, or perhaps also throw like react-test-renderer/shallow will.

@mdjastrzebski
Copy link
Member Author

@yungsters fortunately we don't expose shallow rendering publicly for a long time now. The file you mentioned was for internal use for debug.shallow() which we should remove in #1601.

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

No branches or pull requests

5 participants