upd
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user