Coder Social home page Coder Social logo

Comments (15)

Pagebakers avatar Pagebakers commented on July 28, 2024 1

I sent you the env key that i'm using on the chat.

from flagsmith-js-client.

kyle-ssg avatar kyle-ssg commented on July 28, 2024

Creating a new project with the latest SDK (3.13.0), I am unable to replicate this using a similar set of flags.

Flag

image

User override
image

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.

image

from flagsmith-js-client.

Pagebakers avatar Pagebakers commented on July 28, 2024

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.

kyle-ssg avatar kyle-ssg commented on July 28, 2024

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.

Pagebakers avatar Pagebakers commented on July 28, 2024

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.

Pagebakers avatar Pagebakers commented on July 28, 2024

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.

Pagebakers avatar Pagebakers commented on July 28, 2024

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.

kyle-ssg avatar kyle-ssg commented on July 28, 2024

https://github.com/Flagsmith/issue-152-replication

from flagsmith-js-client.

kyle-ssg avatar kyle-ssg commented on July 28, 2024
>         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.

image

from flagsmith-js-client.

Pagebakers avatar Pagebakers commented on July 28, 2024

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.

Pagebakers avatar Pagebakers commented on July 28, 2024
Screen.Recording.2022-11-02.at.18.33.10.mov

from flagsmith-js-client.

Pagebakers avatar Pagebakers commented on July 28, 2024

After identifying, flagsmith.identity stays undefined

Screenshot 2022-11-02 at 18 40 30

from flagsmith-js-client.

kyle-ssg avatar kyle-ssg commented on July 28, 2024

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

image

Screen.Recording.2022-11-02.at.18.33.10.mov

from flagsmith-js-client.

Pagebakers avatar Pagebakers commented on July 28, 2024

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.

kyle-ssg avatar kyle-ssg commented on July 28, 2024

Following our conversation I'll close this, please re-open if you experience an issue. Thanks

from flagsmith-js-client.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.