https://www.growthbook.io/ logo
w

white-leather-66229

07/15/2022, 6:23 PM
I could use a hand if anyone is available. I have a feature setup in the Cloud version that I have implemented in my Nextjs React app, but the feature always comes back as
null
. Any idea what I'm doing wrong. It appears to be fully published
f

fresh-football-47124

07/15/2022, 6:25 PM
Hi Ryan, where are you checking the state of the feature?
w

white-leather-66229

07/15/2022, 6:28 PM
I'm just logging it out
Thanks for the quick reply btw, much appreciated
f

fresh-football-47124

07/15/2022, 6:29 PM
oh, okay - it's probably a race condition, as the fetch hasn't completed. If you're just testing, add it inside the second then()
or after the setAttributes
any success?
w

white-leather-66229

07/15/2022, 6:44 PM
Same response
f

future-teacher-7046

07/15/2022, 6:51 PM
After setAttributes can you try putting
Copy code
console.log(growthbook.evalFeature("test_feature"))
w

white-leather-66229

07/15/2022, 6:58 PM
Any clue as to what I am doing wrong here?
f

future-teacher-7046

07/15/2022, 8:39 PM
Nothing wrong. The first time your component renders it will return null for the feature. Then after the fetch completes it should re-render your application and it will get the real feature value.
w

white-leather-66229

07/15/2022, 8:45 PM
I see, thank you for the feedback and help. Have a great weekend!
b

better-byte-26469

08/08/2022, 9:30 AM
Hi @white-leather-66229 I have similar problem. I just want to log my feature but it is always null. How did you do it at the end?
w

white-leather-66229

08/08/2022, 12:16 PM
Mine ended up being a race condition in which the feature query when initializing GB was not resolving before my check against the feature or the above
console.log
b

better-byte-26469

08/08/2022, 12:22 PM
Okay, thanks for the reply.