This commit is contained in:
2024-04-12 15:09:46 +05:00
parent 478e1d8be3
commit 74a1b79ee7
+13 -8
View File
@@ -1,4 +1,6 @@
/* eslint-disable react-hooks/rules-of-hooks */
/* eslint-disable @typescript-eslint/no-explicit-any */
import { useNavigate } from "react-router-dom";
import { create } from "zustand";
interface IFunction {
@@ -6,17 +8,20 @@ interface IFunction {
}
interface FunctionState {
functions: IFunction[];
functions: IFunction;
}
const useFunctionStore = create<FunctionState>(() => ({
functions: [
{
test: (value1: any, value2: any) => {
return value1 + value2;
},
const navigate = useNavigate();
const useFunctionStore = create<FunctionState>((set, get) => ({
functions: {
goToUrl: (url: string) => {
navigate(url);
},
],
},
callFunction: (name: string) => {
get().functions[name].apply(get().functions, []);
},
}));
export default useFunctionStore;