Encountering some bizarre behavior with `@growthbo...
# announcements
m
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?
f
Hi Josh, we would be happy to help you debug it if you like
a
Updating here as I work with Josh; it results from a separate nx
lib
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
Copy code
const growthbookContext = useContext(GrowthbookContext);
reads from the wrong context/module and has no
growthbook
object defined.
f
👍
a
Good to know of your openings using calendly though! We will keep that in mind 🙂