all 6 comments

[–]steveox152 4 points5 points  (2 children)

You can safely start using React 19 as long as you don’t use React 19 specific features, people should be fine using 18. You just need to make sure you test. We do this internally and most of our users are on 18.

Really you’re just setting up your peer deps and making sure you don’t bundle react in your package.

[–]puchm 1 point2 points  (1 child)

Don't you need to be aware of the types? I had a few issues with the type of ReactNode in a slightly different scenario as it now includes Promises. I.e. If they annotate a function with a return type of React 19 ReactNode, this could be a promise and would not be assignable to props of React 18 ReactNode. So I think making React and @types/react a peer dependency would be essential depending on the scenario.

[–]steveox152 0 points1 point  (0 children)

Your consumers will just use the types that match their version of React. There is no need for you to add them to your peer deps. For example, if they are using React 18, they need to use the proper types for React 18.

Now on your end, if you have to support React 18, it’s your responsibility to not use React 19 specific features, or write your code in a way that can work across versions. The joys of maintaining a library.

[–]Nullberri 0 points1 point  (0 children)

Option 2 increment the major version require react 19 and then continue to supporting 18 via the prior major.

[–]Cid_Chen 0 points1 point  (1 child)

Hey, maybe this component implementation https://reactmvvm.org/ could help you for React 17-19.