Skip to content

Instantly share code, notes, and snippets.

@Karthik-B-06
Last active November 1, 2020 14:13
Show Gist options
  • Save Karthik-B-06/3329dd2d0f2a0a7f903e373fa1258ed1 to your computer and use it in GitHub Desktop.
Save Karthik-B-06/3329dd2d0f2a0a7f903e373fa1258ed1 to your computer and use it in GitHub Desktop.
import create from 'zustand';
interface ToastType {
showToast: boolean;
toastMessage: string;
toastIcon: JSX.Element | React.FC | null;
}
interface ToastStore extends ToastType {
setShowToast: (values: ToastType) => void;
}
export const defaultToastValues = {
showToast: false,
toastMessage: '',
toastIcon: null,
};
const useToastStore = create<ToastStore>((set, get) => ({
...defaultToastValues,
setShowToast: (values: ToastType) => set({ ...get(), ...values }),
}));
export default useToastStore;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment