Creating custom components in React
When we look at our App
class, we can see that it is useful to have a class that has a state and functions that can be utilized to manage how and when HTML is rendered to the browser. When it comes to individual to-do items, we could use a state and functions. This is because we have a button that gets attributes from the to-do item and calls the Rust server to either edit or delete it. In this section, we are going to build two components: a ToDoItem
component in the src/components/ToDoItem.js
file and a CreateToDoItem
component in the src/components/CreateToDoItem.js
file. Once we have built these, we can plug them into our App
component as our App
component will get the items’ data and loop through these items, creating multiple ToDoItem
components. There are a few steps that we need to process to achieve this, so this section will be split into the following subsections:
- Creating our
ToDoItem
component - Creating our
CreateToDoItem...