crootfast
Version:
大前端工程化命令行脚手架
30 lines (23 loc) • 647 B
JavaScript
import React, { createContext } from "react";
import useReactive from "@/common/hooks/useReactive";
import { set, get } from "lodash-es";
const centerContextState = {
state: {}
};
const CenterContext = React.createContext(centerContextState);
function put(path, value = "", data = centerContextState) {
if (!path) {
throw "The path parameter cannot be empty!";
}
return set(data, path, value);
}
function query(path = "", data = centerContextState) {
return get(data, path);
}
function useStores() {
return (
<CenterContext.Provider value={{ put, query }}>
</CenterContext.Provider>
)
}
export default useStores;