react-feature-flags
react-feature-flags copied to clipboard
New feature: Implement a way to associate a constant through a "useFlag()" or "useFeatureFlag()"
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 },
]}
/>