import { useState } from 'react';
import { Button, Textarea } from "@canonical/react-components";
function App() {
const [data, setData] = useState("Default text");
return (
<div>
<Button onClick={() => setData("")}>
Show nothing
</Button>
<p>Current data is: {data}</p>
<Textarea
value={data}
onChange={(e) => setData(e.target.value)}
/>
</div>
);
}
This is the default scenario:
I'd expect clicking the button to clear the value in the Textarea. However, while the state is correctly updated (to an empty string), the Textarea still shows the previous value.
Consider this simplified example:
This is the default scenario:
I'd expect clicking the button to clear the value in the
Textarea
. However, while the state is correctly updated (to an empty string), theTextarea
still shows the previous value.