native-variants
Version:
A library for handling variants in React Native components with theme support.
25 lines • 822 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.createCTX = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = require("react");
const createCTX = () => {
const Context = (0, react_1.createContext)(undefined);
const CTXProvider = ({ children, props, }) => {
const value = (0, react_1.useMemo)(() => ({ props }), [props]);
return (0, jsx_runtime_1.jsx)(Context.Provider, { value: value, children: children });
};
const useCTX = () => {
const context = (0, react_1.useContext)(Context);
if (!context) {
return undefined;
}
return context.props;
};
return {
CTXProvider,
useCTX,
};
};
exports.createCTX = createCTX;
//# sourceMappingURL=create-provider.js.map