Skip to content

Instantly share code, notes, and snippets.

@JamesZoft
Last active August 26, 2019 12:56
Show Gist options
  • Save JamesZoft/259a9456ba1064f7cb65d311cbe7d74a to your computer and use it in GitHub Desktop.
Save JamesZoft/259a9456ba1064f7cb65d311cbe7d74a to your computer and use it in GitHub Desktop.
const saveStuffToBackend = stuff => {
saveToBackend(stuff);
}
const genRowPartial = (foo) => (bar) => {
const [baz, setBaz] = useState(0);
return (
<tr><td><input value={baz} onChange={e => setBaz(e.target.value)} onBlur={() => saveStuffToBackend(baz)} /></td></tr>
);
}
const MyComponent = props => {
const genRow = genRowPartial(props.stuff);
return (
<table><tbody>
{props.stuff.map(el => genRow(el))}
</tbody></table>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment