Files
react/compiler/crates/react_hermes_parser/tests/fixtures/ref-in-effect.js
2024-04-02 16:49:31 -07:00

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