import { useCallback , useState } from 'react' ; interface SelectedState { selected : boolean ; lastUpdate : number ; } export function useSelectionState ( initialSelectionState ) { const [ state , setState ] = useState < SelectedState > ( { selected : initialSelectionState , lastUpdate : 0 } ) ; const setSelected = useCallback ( ( selected ) => { setState ( { selected , lastUpdate : Date . now ( ) } ) ; } , [ ] ) ; return [ state . selected , state . lastUpdate , setSelected ] ; }