UNPKG

antd-mobile

Version:
9 lines 272 B
import { useEffect, useRef, useState } from 'react'; export function useRefState(initialState) { const [state, setState] = useState(initialState); const ref = useRef(state); useEffect(() => { ref.current = state; }, [state]); return [state, setState, ref]; }