mirror of
https://github.com/facebook/react.git
synced 2026-02-26 05:25:05 +00:00
11 lines
283 B
JavaScript
11 lines
283 B
JavaScript
function Component(props) {
|
|
const [x, setX] = useState(null);
|
|
|
|
const onChange = (e) => {
|
|
let x = null; // intentionally shadow the original x
|
|
setX((currentX) => currentX + x); // intentionally refer to shadowed x
|
|
};
|
|
|
|
return <input value={x} onChange={onChange} />;
|
|
}
|