React SDK - passing context and initialization #171
Replies: 1 comment
-
In answer to (1), the context and config that has been initialized within the class in the ReactSDK is set globally in the window context. It happens at this location https://github.com/featurehub-io/featurehub-javascript-sdk/blob/main/featurehub-react-sdk/src/components/FeatureHub.tsx#L64 Because it is set globally for the window, you can then grab it in your code as FeatureHub.context() - see here https://github.com/featurehub-io/featurehub-javascript-sdk/blob/main/featurehub-javascript-client-sdk/app/index.ts#L36 and do the code from (1) above. To answer (2), in React, SDK initialization happens when you wrap the class around your code, it assumes from that point down you want access to features, so currently the answer is that you would have to push that class further down or create your own variant of this one file and make it do what you wish, the React SDK is just window-dressing on top of the client-sdk. However, we would be happy to add a "delayInitialization" field (or similar) to make it do this for you. If that is of interest, please feel free to raise an issue in the Issues section and we'll see what we can do for you! |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
All reactions