Placing the Context
Place the context in the code in this lesson.
We'll cover the following...
Okay, now for the fun part. Here’s the App component:
import * as React from "react"import { Venue } from "./venue"import {TicketData,VenueAction,VenueState,initialState,venueReducer,} from "./venue_reducer"export interface AppProps {concertId: numberrows: numberseatsInRow: numberotherHeldTickets: TicketData[]}export interface IsVenueContext {state: VenueStatedispatch: React.Dispatch<VenueAction>}export const VenueContext = React.createContext<IsVenueContext>(null)export const App = (props: AppProps) => {const [state, dispatch] = React.useReducer(venueReducer,initialState(props))return (<VenueContext.Provider value={{ state, dispatch }}><Venue /></VenueContext.Provider>)}
Declarations
Most of this is declarations. We start by importing from React and then importing ...