14 lines
No EOL
317 B
Markdown
14 lines
No EOL
317 B
Markdown
Basics
|
|
|
|
```js
|
|
const [name, setName] = useState('Edward');
|
|
const [age, setAge] = useState('0');
|
|
|
|
|
|
function handleClick() {
|
|
setName('Taylor');
|
|
setAge(a => a + 1);
|
|
}
|
|
```
|
|
|
|
as react batches states updates so it when it is called multiple times it may not update correctly so this updater function/functional form helps |