Affected: React Web SDK 3.0
Overview
Sometimes, your context is unavailable on the application load, and you must initialize it later. The React SDK supports deferring initialization for this scenario.
Solution
When configuring the React SDK, optionally, you can choose to use the deferInitialization
property which allows you to defer SDK initialization until you define the context
property.
If you prefer to have deferInitialization
set to true
and not send any context data, then you will need to set the context prop on LDProvider
to initialize the ldClient
.
Example:
const context: LDContext = { key: 'john', kind: 'user', name: 'john doe' };
const newProps = { ...props, context };
const UpdatedLaunchDarklyApp = (
//The context prop will initialize the ldClient
<LDProvider {...newProps}>
<App />
</LDProvider>
);