https://www.growthbook.io/ logo
#announcements
Title
# announcements
m

millions-father-50159

05/06/2022, 8:11 PM
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

fresh-football-47124

05/07/2022, 3:41 AM
Hi Josh, we would be happy to help you debug it if you like
a

adamant-mechanic-29511

05/07/2022, 7:39 PM
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

fresh-football-47124

05/07/2022, 7:40 PM
👍
a

adamant-mechanic-29511

05/07/2022, 7:40 PM
Good to know of your openings using calendly though! We will keep that in mind 🙂
15 Views