Skip to content

Ergonomic changes? Or maybe I'm missing something #35

Description

@from-nibly

Really excited about flagsmith. Just getting started with react.

I'm glad there are hooks available but right now I'm finding myself writing a wrapper hook to make it work better in my project. Am I ttly doing this wrong?

As far as I understand I only want to identify the user once, start listening, and subscribe once. Then throughout the app I might grab the value of feature flags.

But right now I've written a hook to ensure things are initialized, and is listening, and then another hook that uses that to just grab a value. Am I missing something?

I would like to just be able to do something like

const myFeature = () => {
  const {value, error} = useFlag('my_flag_name');
  
  if (error) {
    return <>ERROR: {error.toString()}</>
  }
  if (value == undefined) {
     return <>Loading</>
  }
  
  // use the value in some part of the component here.
};

Is there a reason that the initialization, subscribing, and identification, and getValue is all together in the same hook?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions