HTML Lists
Work with HTML lists using React and Transcrypt.
We'll cover the following...
Introduction
In this lesson, we will build upon what we went over previously and learn how we can dynamically add and remove elements in our application through examples.
For this example, we are going to take the application code from the previous chapter. Instead of just displaying an alert when we click the “Submit” button, we will add the value in the input box to a list of displayed items. This time around, we are going to keep the HTML file and pyreact.py
module the same as last time and update the app.py
file as shown here.
Adding states
Most of our core React App
components are the same, but we add a few things to support the list we want to build. The first thing we do is store our list items. In line 5, by using the React.useState()
method, we add a new state variable to our code called listItems
. This also gives us the ...