react-feature-flags icon indicating copy to clipboard operation
react-feature-flags copied to clipboard

New feature: Implement a way to associate a constant through a "useFlag()" or "useFeatureFlag()"

Open gleissonneves opened this issue 9 months ago • 0 comments

I see that, just as the use of the Flag tag is an indirect means of associating the featureFlag constant with the rendering scenario, it would be important to make a context use available for variable usage scenarios.

// not implemented featureFlag
<Dropdown
        options={[
          { label: "Update", onClick: () => console.log("Update: " + id), disable: true },
          { label: "Delete", onClick: () => console.log("Delete: " + id), disable: true },
        ]}
/>
// implemented featureFlag
const useFeatureFlagCanUpdate = useFeatureFlag('update');
const useFeatureFlagCanDelete = useFeatureFlag('delete');

<Dropdown
        options={[
          { label: "Update", onClick: () => console.log("Editar: " + id), disable: useFeatureFlagCanUpdate  },
          { label: "Delete", onClick: () => console.log("Excluir: " + id), disable: useFeatureFlagCanDelete },
        ]}
/>

gleissonneves avatar Mar 23 '25 14:03 gleissonneves