import { type UseHook } form "./useHookShared";
import { useHookOld } from "./useHookOld";
import { useHookNew } from "./useHookNew";
type MyComponentProps = {
id: string;
variant?: "default" | "bold",
}
export function MyComponent(props: MyComponentProps) {
const featureFlag = useFeatureFlag();
return featureFlag
? <MyComponentImplementation key="feature-on" {...props} useHook={useHookNew} />
: <MyComponentImplementation key="feature-off" {...props} useHook={useHookOld} />
}
type MyComponentImplementationProps = MyComponentProps & {
useHook: UseHook;
}
function MyComponentImplementation({
useHook,
id,
variant = "default"
}: MyComponentImplementationProps) {
const result = useHook();
// ...
};
-
Notifications
You must be signed in to change notification settings - Fork 0
echobind/conditional-hooks
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
Demo different options for conditional hooks
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published