1 | import { useEffect, useRef, useState } from 'react';
|
2 | export function useRefState(initialState) {
|
3 | const [state, setState] = useState(initialState);
|
4 | const ref = useRef(state);
|
5 | useEffect(() => {
|
6 | ref.current = state;
|
7 | }, [state]);
|
8 | return [state, setState, ref];
|
9 | } |
\ | No newline at end of file |