An open API service indexing awesome lists of open source software.

https://github.com/echobind/conditional-hooks

Demo different options for conditional hooks
https://github.com/echobind/conditional-hooks

Last synced: 4 months ago
JSON representation

Demo different options for conditional hooks

Awesome Lists containing this project

README

          

# readme

```ts
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
?
:
}

type MyComponentImplementationProps = MyComponentProps & {
useHook: UseHook;
}

function MyComponentImplementation({
useHook,
id,
variant = "default"
}: MyComponentImplementationProps) {
const result = useHook();

// ...
};
```