UNPKG

antd-mobile

Version:

<img src="https://gw.alipayobjects.com/mdn/rms_ee68a8/afts/img/A*hjjDS5Yy-ooAAAAAAAAAAAAAARQnAQ" alt="logo" width="100%" />

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]; }