forked from pu428f3pz/InternshipProject
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
13 lines
353 B
13 lines
353 B
import * as React from 'react';
|
|
import useForceUpdate from './useForceUpdate';
|
|
export default function useSyncState(initialValue) {
|
|
var ref = React.useRef(initialValue);
|
|
var forceUpdate = useForceUpdate();
|
|
return [function () {
|
|
return ref.current;
|
|
}, function (newValue) {
|
|
ref.current = newValue; // re-render
|
|
|
|
forceUpdate();
|
|
}];
|
|
} |