We are now going to make the App component dynamic by adding functionality to fetch, add, toggle, filter, and remove todo items. Furthermore, we are going to define a StateContext provider.
Let's start making the App component dynamic:
- In src/App.js, import the StateContext, after the other import statements:
import StateContext from './StateContext'
- Then, import the fetchAPITodos and generateID functions from the src/api.js file:
import { fetchAPITodos, generateID } from './api'
- Next, we are going to modify our App class code, implementing a constructor, which will set the initial state:
export default class App extends React.Component { constructor (props) {
- In this constructor, we need to first call ...