mirror of
https://github.com/facebook/react.git
synced 2026-02-26 07:55:55 +00:00
12 lines
265 B
JavaScript
12 lines
265 B
JavaScript
function Component(props) {
|
|
const ref = useRef(null);
|
|
const onChange = (e) => {
|
|
const newValue = e.target.value ?? ref.current;
|
|
ref.current = newValue;
|
|
};
|
|
useEffect(() => {
|
|
console.log(ref.current);
|
|
});
|
|
return <Foo onChange={onChange} />;
|
|
}
|