@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.
15 lines (11 loc) • 462 B
text/typescript
import { useContext } from 'react'
import { useShallow } from 'zustand/shallow'
import { FormStoreContext } from './FormStoreContext.js'
import type { FormValuesState } from './types.js'
export function useFormStore<T>(selector: (state: FormValuesState) => T): T {
const useStore = useContext(FormStoreContext)
if (!useStore) {
throw new Error('You forgot to wrap your component in <FormStoreProvider>.')
}
return useStore(useShallow(selector))
}