Now that you've got some of the basics, we'll introduce a more complicated element. In the remainder of this tutorial, you'll build a to-do list component. Here we've provided some of the boilerplate for your to-do-list.

Since the list items are private to the component, the _listItems property is defined as internal reactive state. It works just like a reactive property, but it isn't exposed as an attribute, and shouldn't be accessed from outside the component. For more information, see Public properties and internal state.

You can use standard JavaScript in Lit expressions to create conditional or repeating templates. In this step, you'll use map() to turn an array of data into a repeating template.

Try entering a new item and clicking Add.

Mutating objects and arrays.

Note that instead of mutating the _listItems array, addToDo() creates a new array that includes the new item. Using this immutable data pattern ensures that the components see the new data. For more information, see Mutating objects and arrays.