import * as React from 'react' ; const useRefState = < T = unknown > ( a ) : [ T , ( val : T ) => void , React . MutableRefObject < T > ] => { const [ state , _setState ] = React . useState ( a ) ; const stateRef = React . useRef ( state ) ; const setState = ( val ) : void => { stateRef . current = val ; _setState ( val ) ; } ; return [ state , setState , stateRef ] ; } ; export default useRefState ;