[Solved] React – interview exercise


I know an answer has been accepted, but it doesn’t actually satisfy the requirements fully, i.e.

Each callback should take a single, integer value as a parameter which is the amount to increment the counter’s existing value by.

The accepted answer takes the event object as a parameter which is not the specified requirement. The only way to strictly satisfy the expected requirement is to bind unique

“…onIncrement callbacks as props…”

for each counter. This approach has drawbacks and performance implications as discussed in this article

Working example at https://codesandbox.io/s/j2vxj620z9

1

solved React – interview exercise