import { Atom } from '@theatre/dataverse' ; import { useLayoutEffect , useMemo } from 'react' ; export default function useValToAtom < S > ( val ) { const atom = useMemo ( ( ) => { return new Atom ( val ) ; } , [ ] ) ; useLayoutEffect ( ( ) => { atom . setState ( val ) ; } , [ val ] ) ; return atom ; }