Defining the StateContext

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:

  1. Create a new src/StateContext.js file.
  2. Import React, as follows:
import React from 'react'
  1. Now, define the StateContext and set an empty array as the fallback value:
const StateContext = React.createContext([])
  1. Finally, export the StateContext:
export default StateContext

Now, we have a context where we can store our array of todo items.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.219.22.107