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