busy-horse-73824
10/17/2022, 3:12 PMgrowthbook.setFeatures
, setAttributes
, etc do not trigger a re-render (because the context provider's value doesn't change), and there's nothing in the hooks etc to compensate for that
Currently the only safe way to use growthbook with react is to treat the GrowthBook class as being immutable - any other way, it's fundamentally brokensubscribe
on growthbook-react is risky. In React projects, this terminology would typically indicate it being a way to know when mutable fields change
Provided a screenshot of how code would typically be written to make use of this
But it actually seems to only be used in a very specific & entirely undocumented situation? (with run
)future-teacher-7046
growthbook.setFeatures
and growthbook.setAttributes
should cause the GrowthBookProvider to re-render. The context value doesn't change, but the Provider has an internal state that gets updated that should trigger a re-render. If that's not happening, it may be a bug that we can look into.
• growthbook.subscribe
is an internal method with a very niche use case. I agree the naming isn't great there - one of the reasons we haven't added it our documentation.busy-horse-73824
10/18/2022, 12:25 PMsetRenderer
thing (which we thought would be something we had to implement against), but thought in practice it probably wouldn't be the best approach
I would note that it won't work if you use the growthbook instance with multiple providers - might be worth making it subscription based, and then cases like ours can leverage that too