Encountering some bizarre behavior with
@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?