UNPKG

@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 1.06 kB
import { jsx as _jsx } from "react/jsx-runtime"; import { createContext, useContext, useRef } from 'react'; import { useShallow } from 'zustand/shallow'; import { createRouteExecutionStore } from './createRouteExecutionStore.js'; const RouteExecutionStoreContext = createContext(null); export function RouteExecutionStoreProvider({ children, ...props }) { const storeRef = useRef(null); if (!storeRef.current) { storeRef.current = createRouteExecutionStore(props); } return (_jsx(RouteExecutionStoreContext.Provider, { value: storeRef.current, children: children })); } export function useRouteExecutionStoreContext() { const useStore = useContext(RouteExecutionStoreContext); if (!useStore) { throw new Error(`You forgot to wrap your component in <${RouteExecutionStoreProvider.name}>.`); } return useStore; } export function useRouteExecutionStore(selector) { const useStore = useRouteExecutionStoreContext(); return useStore(useShallow(selector)); } //# sourceMappingURL=RouteExecutionStore.js.map