Skip to content

Latest commit

 

History

History
34 lines (27 loc) · 757 Bytes

README.md

File metadata and controls

34 lines (27 loc) · 757 Bytes

readme

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();

  // ...
};