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

React 18 Support #156

Closed
elliotwestlake opened this issue Apr 13, 2022 · 3 comments
Closed

React 18 Support #156

elliotwestlake opened this issue Apr 13, 2022 · 3 comments

Comments

@elliotwestlake
Copy link

elliotwestlake commented Apr 13, 2022

We're currently upgrading to React 18 but getting this type error:

error TS2322: Type '{ children: Element; optimizely: ReactSDKClient; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<OptimizelyProvider> & Readonly<OptimizelyProviderProps>'.
  Property 'children' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<OptimizelyProvider> & Readonly<OptimizelyProviderProps>'.

108     <OptimizelyProvider optimizely={optimizelyClientInstance}>

Would be nice for the repo to be updated to React 18, however, I see that's going to require a fair amount of work as you guys are using enzyme which doesn't look like it's going to support React 18 ever. So may need to migrate to RTL.

The simplest solution I can see now is to explicitly define a children prop to satisfy React 18.

https://reactjs.org/blog/2022/03/08/react-18-upgrade-guide.html#updates-to-typescript-definitions

Be great to hear your thoughts.

Thanks!

@opti-jnguyen
Copy link
Contributor

Thanks for the input @wizardels - will discuss this issue with the team and post an update when we've decided on an approach to address it!

zashraf1985 added a commit that referenced this issue May 17, 2022
## Summary
React 18 required `children` prop to be explicitly defined. This PR fixes this to make the React SDK work with React 18.
https://reactjs.org/blog/2022/03/08/react-18-upgrade-guide.html#updates-to-typescript-definitions

## Test Plan
All existing tests pass

## Issues
#156
@opti-jnguyen
Copy link
Contributor

@elliotwestlake - FYI, v2.9.0 was released last week with the recent changes incorporating React 18 compatibility.

https://github.com/optimizely/react-sdk/releases/tag/2.9.0

Please check it out and feel free to post here with any feedback. Thanks again for bringing up this issue!

@elliotwestlake
Copy link
Author

@opti-jnguyen Amazing, thanks so much for your help!

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

2 participants