launchdarkly / react-client-sdk

LaunchDarkly Client-side SDK for React.js
Other
81 stars 67 forks source link

LDProvider doesn't work with React 18/Typescript #129

Closed mikecousins closed 2 years ago

mikecousins commented 2 years ago

Is this a support request? No.

Describe the bug If you upgrade to React 18 in a React/Typescript project you'll get compilation errors when using LDProvider.

Type '{ children: ReactNode; clientSideID: string; user: { anonymous: true; custom: { location: string; }; }; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<LDProvider> & Readonly<ProviderConfig>'.
  Property 'children' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<LDProvider> & Readonly<ProviderConfig>'.

To reproduce Upgrade to react 18 and @types/react 18

Expected behavior Compile without errors.

Logs None

SDK version 2.25.1

Language version, developer tools react: 18.0.0 react-dom: 18.0.0 @types/react: 18.0.0 @types/react-dom: 18.0.0 typescript: 4.6.3

OS/platform Any

Additional context You probably need to wrap your Props with a PropsWithChildren<Props>

louis-launchdarkly commented 2 years ago

Hello @mikecousins, thank you for reaching out. We are working on this right now, and we will give you another update when we are ready to release the update.

louis-launchdarkly commented 2 years ago

Hello @mikecousins, we just released the fix for this issue in https://github.com/launchdarkly/react-client-sdk/releases/tag/2.25.2

Please try it out and let us know how it goes.

munkacsimark commented 2 years ago

I had the same issue, and 2.25.2 fixed for me.