In the previous post I added a React Native toggle button. In this post I will add and remove list items.
We’re going to be storing an array of meetings, adding to it and removing from it.
First, we extract a meeting into a specialized class.
The first thing to notice is the usage of props. These are passed into the Meeting component at creation time via a constructor(props). It’s possible to declare required props for a component using propTypes.
The parent component renders a list of meetings inside a scrollable view.
A meeting has a start and an end date, so we will also need to remember when a meeting started.
A meeting is pushed into the meetings array when it ends.
A meeting can be removed from the meetings array by key.