Skip to content

Instantly share code, notes, and snippets.

Last active Jan 29, 2020
What would you like to do?
const darkTheme = {
name: 'dark',
background: 'black',
text: 'white',
const lightTheme = {
name: 'light',
background: 'white',
text: 'black',
function reducer(state, actionName, payload) {
switch (actionName) {
case 'toggleTheme':
return {
theme: === 'light' ? darkTheme : lightTheme,
throw new Error(`Action does not exist: ${actionName}`);
const appState = new GlobalState(reducer, { theme: lightTheme });
export default appState;
Copy link

DominicTobias commented Jan 29, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment