Skip to content

Instantly share code, notes, and snippets.

@arthurvi
Created October 5, 2020 09:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arthurvi/fbf7ffe806a7fb9e6a38ae730060314e to your computer and use it in GitHub Desktop.
Save arthurvi/fbf7ffe806a7fb9e6a38ae730060314e to your computer and use it in GitHub Desktop.
ItemWrapper.jsx
function ItemWrapper({ item, setItems }) {
const handleChange = React.useCallback(
function handleChange(value) { ... },
[item, setItems]
);
const handleSave = React.useCallback(
async function handleSave() {
// set isSaving to true
await save(item);
// set isSaving to false
},
[item]
);
return (
<Item
id={item.id}
value={item.value}
isSaving={item.isSaving}
onSave={handleSave}
onChange={handleChange}
/>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment