@mrii/react-table-builder
Version:
library to easily build tables using MUI grid
29 lines (26 loc) • 890 B
JavaScript
import { jsx } from 'react/jsx-runtime';
import { useContext, useMemo, createContext as createContext$1 } from 'react';
const createContext = ()=>{
const BaseContext = /*#__PURE__*/ createContext$1(undefined);
const Provider = ({ value , children })=>{
return /*#__PURE__*/ jsx(BaseContext.Provider, {
value: value,
children: children
});
};
const useProps = (selector = (v)=>v)=>{
const context = useContext(BaseContext);
if (typeof context === 'undefined') throw new Error('You must use `useProps` in children of its `Provider`');
const memoizedValue = useMemo(()=>selector(context), [
selector,
context
]);
return memoizedValue;
};
return [
Provider,
useProps
];
};
export { createContext };
//# sourceMappingURL=create-context.mjs.map