I've been trying to follow along with a code example but I couldn't figure out what the syntax in the method updateInputValues [type]: value
means. My guess is that it updates the state variable input
based on whether the type passed in is limit or start, but I am not sure.
const [input, updateInput] = useState({ limit: 5, start: 0 })
//function to let users update input value
function updateInputValues(type, value) {
updateInput({ ...input, [type]: value })
}
//input fields to take user input
<input
onChange={e => updateInputValues('limit', e.target.value)}
placeholder="limit"
/>
<input
placeholder="start"
onChange={e => updateInputValues('start', e.target.value)}
/>