Binding specific values to events is a common occurrence in a React application. Let's kick this off with a common example. Here we have a <Button />
that calls a click handler with a specific argument: entity
. There are several things wrong here.
Note: we will be refactoring this example as we go along.
- We're binding a function in the
render
method - We're binding two props together in the child component
- We're breaking with several established naming conventions
- We're using a class component when a functional component will suffice