Next, we are going to define a context that will keep our current list of todo items. We are going to call this context StateContext.
Let's start implementing the StateContext now:
- Create a new src/StateContext.js file.
- Import React, as follows:
import React from 'react'
- Now, define the StateContext and set an empty array as the fallback value:
const StateContext = React.createContext([])
- Finally, export the StateContext:
export default StateContext
Now, we have a context where we can store our array of todo items.