// documention example function TextFieldExample() { const [value, setValue] = useState('Jaded Pixel'); const handleChange = useCallback((newValue) => setValue(newValue), []); return <TextField label="Store name" value={value} onChange={handleChange} />; }
I see this pattern across the docs. What advantage does it have over the simpler, more common pattern of passing an updated value straighto to useState() like so:
function TextFieldExample() { const [value, setValue] = useState('Jaded Pixel'); return <TextField label="Store name" value={value} onChange={newValue => setValue(newValue)} />; }
Hi, @seandz ,
This is Evita from On The Map.
It's not Polaris function, but React apps callback, you can read more about useCallback here - https://reactjs.org/docs/hooks-reference.html#usecallback
Best,
Evita
Subject | Author | Latest Post |
---|---|---|
Subject | Author | Posted |
---|---|---|
an hour ago | ||
2 hours ago | ||
7 hours ago | ||
yesterday | ||
yesterday |
User | Count |
---|---|
257 | |
165 | |
134 | |
67 | |
38 |