millions-father-50159
05/06/2022, 8:11 PM@growthbook/growthbook-react.
We’re using nx as our mono-repo tool, which could likely be a factor.
We have a specific feature-flags package that houses our FeatureFlagContextProvider component which renders the GrowthbookProvider. This gets imported and rendered at the root of our web-app (separate “package”). If I write some code to useFeature in either of these packages we have no problems.
We then have a separate queries package that houses all of our react-query queries for loading application data. I was attempting to use a feature in one of the queries, however, in debugging it was clear that this line in useFeature const { growthbook } = useContext(GrowthbookContext) was the culprit in that growthbook was undefined. It’s interesting because if I call the function that wraps this logic side by side with useFeature in web-app, the useFeature in web-app correctly gets the feature value whereas the one in queries is unable to because growthbook is undefined.
Anyone encounter a similar issue ever?fresh-football-47124
fresh-football-47124
adamant-mechanic-29511
05/07/2022, 7:39 PMlib treating the module @growthbook/growthbook-react separately (sort've a webpack bundler issue really instead of nx). Solution was to "wrap" and re-export @growthbook/growthbook-react out of our own lib and use that. Otherwise doing something like
const growthbookContext = useContext(GrowthbookContext);
reads from the wrong context/module and has no growthbook object defined.fresh-football-47124
adamant-mechanic-29511
05/07/2022, 7:40 PM