Type Parameters
- T extends IntrinsicAttributes = {}
Returns ((WrappedComponent: React.ComponentType<T>) => React.ComponentType<T>)
A function which accepts your root React component and returns a HOC
- (WrappedComponent): React.ComponentType<T>
Parameters
- WrappedComponent: React.ComponentType<T>
Returns React.ComponentType<T>
withLDProvider
is a function which accepts a config object which is used to initializelaunchdarkly-js-client-sdk
.This HOC handles passing configuration to the
LDProvider
, which does the following:launchdarkly-js-client-sdk
initialize oncomponentDidMount
The difference between
withLDProvider
andasyncWithLDProvider
is thatwithLDProvider
initializeslaunchdarkly-js-client-sdk
atcomponentDidMount
. This means your flags and the ldClient are only available after your app has mounted. This can result in a flicker due to flag changes at startup time.asyncWithLDProvider
initializeslaunchdarkly-js-client-sdk
at the entry point of your app prior to render. This means that your flags and the ldClient are ready at the beginning of your app. This ensures your app does not flicker due to flag changes at startup time.