Current Behavior
When I have code that looks like this:
import { useFeature } from "flagged";
export function Header() {
const hasV2 = useFeature("v2");
return <header>{hasV2 ? <h1>My App v2</h1> : <h1>My App v1</h1>}</header>;
}
createRoot(document.getElementById("root")!).render(
<FlagsProvider features={{ v3: true, moderate: false }}>
<Header />
</FlagsProvider>,
);
We get an exception thrown from this split method
Expected Behavior
Would love for it to essentially default to the flag being off if it can't find the flag in the provider and then do something like a console.warn to let me know that the flag is missing rather than throwing a 'cannot split on undefined' error message.
Suggested Solution(s)
Check if the flag doesn't exit
If the flag requested by the hook doesn't exist, treat it as if the flag were disabled and then throw a warning into the console
Your Environment
| Software |
Version |
| Flagged |
^2.0.8 |
| React |
17 |
| Browser |
Chrome |
| npm/yarn |
npm |
Current Behavior
When I have code that looks like this:
We get an exception thrown from this split method
Expected Behavior
Would love for it to essentially default to the flag being off if it can't find the flag in the provider and then do something like a
console.warnto let me know that the flag is missing rather than throwing a 'cannot split on undefined' error message.Suggested Solution(s)
Check if the flag doesn't exit
If the flag requested by the hook doesn't exist, treat it as if the flag were disabled and then throw a warning into the console
Your Environment