| b69ab31 | 1 | import { useStore } from 'jotai/react'; | ||
| b69ab31 | 2 | import { useCallback } from 'react'; | ||
| b69ab31 | 3 | import type { AtomsSnapshot, Options } from '../types'; | ||
| b69ab31 | 4 | |||
| b69ab31 | 5 | export function useGotoAtomsSnapshot(options?: Options) { | ||
| b69ab31 | 6 | const store = useStore(options); | ||
| b69ab31 | 7 | return useCallback( | ||
| b69ab31 | 8 | (snapshot: AtomsSnapshot) => { | ||
| b69ab31 | 9 | if (store.dev_restore_atoms) { | ||
| b69ab31 | 10 | store.dev_restore_atoms(snapshot.values); | ||
| b69ab31 | 11 | } | ||
| b69ab31 | 12 | }, | ||
| b69ab31 | 13 | [store], | ||
| b69ab31 | 14 | ); | ||
| b69ab31 | 15 | } |