Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normalize components declarations to export default named functions #5

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 16 additions & 13 deletions components/magicui/dot-pattern.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,18 @@ interface DotPatternProps {
className?: string;
[key: string]: any;
}
export function DotPattern({
width = 16,
height = 16,
x = 0,
y = 0,
cx = 1,
cy = 1,
cr = 1,
className,
...props
}: DotPatternProps) {
const DotPattern = (props: DotPatternProps) => {
const {
width = 16,
height = 16,
x = 0,
y = 0,
cx = 1,
cy = 1,
cr = 1,
className,
...restProps
} = props;
const id = useId();

return (
Expand All @@ -32,7 +33,7 @@ export function DotPattern({
"pointer-events-none absolute inset-0 h-full w-full fill-gray-400/40",
className
)}
{...props}
{...restProps}
>
<defs>
<pattern
Expand All @@ -50,6 +51,8 @@ export function DotPattern({
<rect width="100%" height="100%" strokeWidth={0} fill={`url(#${id})`} />
</svg>
);
}
};

export default DotPattern;

export default DotPattern;
20 changes: 11 additions & 9 deletions lib/hooks/use-toast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,24 +169,26 @@ function toast({ ...props }: Toast) {
}
}

function useToast() {
const [state, setState] = React.useState<State>(memoryState)
const useToast = () => {
const [state, setState] = React.useState<State>(memoryState);

React.useEffect(() => {
listeners.push(setState)
listeners.push(setState);
return () => {
const index = listeners.indexOf(setState)
const index = listeners.indexOf(setState);
if (index > -1) {
listeners.splice(index, 1)
listeners.splice(index, 1);
}
}
}, [state])
};
}, [state]);

return {
...state,
toast,
dismiss: (toastId?: string) => dispatch({ type: "DISMISS_TOAST", toastId }),
}
}
};
};

export default useToast;

export { useToast, toast }