@scripty/react-store
Version:
This lightweight global react hook store is inspired by the extjs store architecture. Share your stores through your application with only a few lines of code!
26 lines (22 loc) • 613 B
JSX
import React, { useState } from 'react';
import { StoreContext } from './Context';
window.globalStorage = {
config: {},
data: [
{
name: '',
entries: []
}
],
setStore: () => {}
};
export const StoreProvider = (props) => {
const { defaultStores } = props;
window.globalStorage.config = defaultStores;
let [store, setStore] = useState(window.globalStorage);
return (
<StoreContext.Provider value={{ store: store, setStore: setStore }}>
{props.children}
</StoreContext.Provider>
);
};