Skip to content

Instantly share code, notes, and snippets.

@slashpot
Created August 10, 2020 14:12
Show Gist options
  • Save slashpot/9b110b42d1e54f34bca2136fb0a5dcc2 to your computer and use it in GitHub Desktop.
Save slashpot/9b110b42d1e54f34bca2136fb0a5dcc2 to your computer and use it in GitHub Desktop.
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