Skip to content

Instantly share code, notes, and snippets.

@mohsentaleb
Last active March 6, 2022 07:02
Show Gist options
  • Save mohsentaleb/312b4671b4afbd13e25ff7d2f5fe7a34 to your computer and use it in GitHub Desktop.
Save mohsentaleb/312b4671b4afbd13e25ff7d2f5fe7a34 to your computer and use it in GitHub Desktop.
Anatomy of the app
function App() {
// initialState = { background: "#ccc", content: "Hello World!"}
const [state, dispatch] = useReducer(reducer, initialState);
return (
<AppContext.Provider value={{ state, dispatch }}>
<div className="rect" style={{ backgroundColor: state.background }}>
<span>{state.content}</span>
</div>
<BackgroundControl />
<ContentControl />
</AppContext.Provider>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment