import * as electronRemote from '@electron/remote'; const electronConsole = electronRemote.getGlobal('console') as Console; import Logger from '../../../../logger/logger'; const LOG = Logger.create(__filename, electronConsole); import { useEffect, useSyncExternalStore } from 'react'; import { atom, useSetRecoilState } from 'recoil'; export const exampleState = atom({ key: 'exampleState', default: 4, }); export function useExampleStateSubscription() { LOG.debug('using'); const setExample = useSetRecoilState(exampleState); const value = useSyncExternalStore( () => { LOG.debug('subscribing'); return () => { LOG.debug('unsubscribing') }; }, () => { LOG.debug('returning'); return 6; }, ); useEffect(() => { setExample(value); }, [setExample, value]) }