Created
August 10, 2020 14:12
-
-
Save slashpot/9b110b42d1e54f34bca2136fb0a5dcc2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, {useContext, useReducer} from "react"; | |
import {Counter} from "./component/Counter/Counter"; | |
import "./App.css"; | |
import {CounterContext} from "./context/CounterContext"; | |
import {counterReducer} from "./reducer/counterReducer"; | |
function App() { | |
const defaultState = useContext(CounterContext); | |
const [counterState, counterDispatch] = useReducer(counterReducer, defaultState); | |
return ( | |
<div className="App"> | |
<CounterContext.Provider value={{counterState, counterDispatch}}> | |
<Counter/> | |
</CounterContext.Provider> | |
</div> | |
); | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment