@lifi/widget
Version:
LI.FI Widget for cross-chain bridging and swapping. It will drive your multi-chain strategy and attract new users from everywhere.
24 lines • 978 B
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import { createContext, useContext, useRef, } from 'react';
import { useShallow } from 'zustand/shallow';
import { createSettingsStore } from './createSettingsStore.js';
const SettingsStoreContext = createContext(null);
export const SettingsStoreProvider = ({ children, config, }) => {
const storeRef = useRef(null);
if (!storeRef.current) {
storeRef.current = createSettingsStore(config);
}
return (_jsx(SettingsStoreContext.Provider, { value: storeRef.current, children: children }));
};
export function useSettingsStoreContext() {
const useStore = useContext(SettingsStoreContext);
if (!useStore) {
throw new Error('You forgot to wrap your component in SettingsStoreContext.');
}
return useStore;
}
export function useSettingsStore(selector) {
const useStore = useSettingsStoreContext();
return useStore(useShallow(selector));
}
//# sourceMappingURL=SettingsStore.js.map