-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] - TypeError: Cannot read properties of null (reading 'getValue') #189
Comments
Hi @joelpierre, can you please provide more details and context about this issue, including how can we reproduce it? |
Hey, it turns out it was very bespoke to our setup with server side Algolia not playing ball, however it would be great if in your SDK the useFlag hook didn't do this const res = useMemo(() => {
const res: any = {}
flags.map((k) => {
res[k] = {
enabled: flagsmith!.hasFeature(k), // <------ non-null assertion
value: flagsmith!.getValue(k), // <------ non-null assertion
}
}).concat(traits?.map((v) => {
res[v] = flagsmith!.getTrait(v) // <------ non-null assertion
})) As you can see the |
Hey again, I think maybe we could, however I'm not sure what cases would exist where the Flagsmith Providers don't get a Flagsmith instance. Was there a good example that I'm maybe not understanding? |
With Algolia SSR they want you to do some pretty weird and wonderful things for server side rendering as you can see here: https://www.algolia.com/doc/guides/building-search-ui/going-further/server-side-rendering/react/#with-nextjs and as a result we have to pre-render the Algolia listing "stuff" server side and renderToString... in essence all our _app providers are not loaded in this serverState until hydration kicks in on the client. It would be good if flagsmith didn't blow up though haha as I went down a rabit hole debugging it 😬 . OR if there was more of a check to ensure the provider state was set before trying to do anything further? |
Hi there, could you please include a sample minimal project failing, and a clear description of what would be the expected behavior? |
We're going to close this issue due to inactivity. Please feel free to reopen it if you have the required information. |
Currently seeing the below, I think there may be some guard clauses missing before calling "getValue"
The text was updated successfully, but these errors were encountered: