Comments (15)
I sent you the env key that i'm using on the chat.
from flagsmith-js-client.
Creating a new project with the latest SDK (3.13.0), I am unable to replicate this using a similar set of flags.
Flag
App Code
<FlagsmithProvider flagsmith={flagsmith} options={{ environmentID:"FrSKH5vQ7AGcCJ5KfbDok5", }}>
{...yourpage}
</FlagsmithProvider>
Page Code
const Home = () => {
const flags = useFlags(["cloud_beta_access"])
const flagsmith = useFlagsmith()
useEffect(()=>{
console.log("Flags changed")
},[flags])
return (
<div className="App">
{
flagsmith.identity? (
<button onClick={()=>flagsmith.logout()}>
Logout
</button>
): (
<button onClick={()=>{
flagsmith.identify("flagsmith_sample_user")
}}>
Identify
</button>
)
}
</div>
);
}
From the above, identifying re-renders due to flags changing.
from flagsmith-js-client.
Thanks @kyle-ssg this was our guess as well, I tried adding cloud_beta_access.enabled
to deps, without any difference.
React.useEffect(() => {
if (!flags.cloud_beta_access?.enabled) {
// do something
// enabled is always false and value is null
// expected to be updated to the user override value
}
}, [flags.cloud_beta_access?.enabled])
Will try your approach as well to see if it changes anything.
But in any case I would expect doing a console.log(flags)
directly in the render function to always have the latest values in there, which it doesn't.
from flagsmith-js-client.
Hey, @Pagebakers, actually, trying to replicate this I can see that flags always have the latest value. I can create a git repository with replication if this helps?
useEffect(()=>{
console.log("Flags changed", flags.cloud_beta_access.enabled) // always inline with the latest value.
},[flags])
from flagsmith-js-client.
Really strange, it's always out of date here.
Please note that we have these settings for the feature.
cloud_beta_access
default
enabled: false
value: false
user override
enabled: true
value: true
Whatever I do, useFlags always returns enabled: false, value: null
even with a direct pointer to enabled or value.
from flagsmith-js-client.
Hey, @Pagebakers, actually, trying to replicate this I can see that flags always have the latest value. I can create a git repository with replication if this helps?
useEffect(()=>{ console.log("Flags changed", flags.cloud_beta_access.enabled) // always inline with the latest value. },[flags])
That'd be great
from flagsmith-js-client.
Regarding your code
const Home = () => {
const flags = useFlags(["cloud_beta_access"])
const flagsmith = useFlagsmith()
useEffect(()=>{
console.log("Flags changed") // this triggers indeed, but values don't change.
console.log(flags) // {cloud_beta_access: {enabled: false, value: null}}
},[flags])
return (
<div className="App">
{
flagsmith.identity? (
<button onClick={()=>flagsmith.logout()}>
Logout
</button>
): (
<button onClick={()=>{
flagsmith.identify("flagsmith_sample_user")
}}>
Identify
</button>
)
}
</div>
);
}
from flagsmith-js-client.
https://github.com/Flagsmith/issue-152-replication
from flagsmith-js-client.
> console.log("Flags changed") // this triggers indeed, but values don't change.
> console.log(flags) // {cloud_beta_access: {enabled: false, value: null}}
If it triggers then definitely flags have the latest value, I've updated the replication to also show this.
from flagsmith-js-client.
Not sure what is going on here, but i have the same issues in your repo.
When clicking Identify doesn't update the state either. (I do see the request being succesful)
Could it be something in my account settings?
Same issues in Chrome and Safari.
from flagsmith-js-client.
Screen.Recording.2022-11-02.at.18.33.10.mov
from flagsmith-js-client.
After identifying, flagsmith.identity
stays undefined
from flagsmith-js-client.
Sorry, I'm a bit confused here. Is this cloning the repository and running without changing code? Doing the same, I get the results of my previous gif.
https://github.com/Flagsmith/issue-152-replication
Screen.Recording.2022-11-02.at.18.33.10.mov
from flagsmith-js-client.
It looks like it's related to the env key/id
With my keys (dev/prod) it isn't working, but with your it's working fine.
from flagsmith-js-client.
Following our conversation I'll close this, please re-open if you experience an issue. Thanks
from flagsmith-js-client.
Related Issues (20)
- Case sensitive flags are lower cased when trying to retrieve values
- isLoading never updates to false if flag is disabled (React useFlagsmith hook) HOT 5
- Clear cache when calling logout() HOT 5
- the value obtained is sometimes not appropriate HOT 2
- Don't call getFlags() if the identity set is the same HOT 6
- error TS2304: Cannot find name 'bool'
- Provide explicit setter functions for Data Dog / Dynatrace HOT 1
- Improve useFlagsmithLoading
- Cannot read properties of null (reading 'getValue') HOT 4
- isLoading never updates to false HOT 2
- Flagsmith's `loadingState.error` is not respect actual error state HOT 11
- [Bug] - NextJS >= 13.0.0 SSR `useFlagsmith` state not matching the state that is passed to the provider. HOT 16
- flagsmith/react only works in React 18 HOT 3
- [Bug] - TypeError: Cannot read properties of null (reading 'getValue') HOT 5
- Flagsmith's 'useFlags' doesn't return actual cached flags when request failed HOT 2
- Rollup Name for react HOT 5
- Inconsistent license information HOT 2
- Caching with multiple instance doesn't work HOT 6
- Typing issue in react.tsx: 'flagsmith' is possibly 'null' HOT 3
- useFlags() race condition HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flagsmith-js-client.