Skip to content

Instantly share code, notes, and snippets.

@ryandrewjohnson
Created February 27, 2018 03:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryandrewjohnson/3d70f44108c180640fd08e89f226dbeb to your computer and use it in GitHub Desktop.
Save ryandrewjohnson/3d70f44108c180640fd08e89f226dbeb to your computer and use it in GitHub Desktop.
const languages = (state = [], action) => {
// reducer logic here
};
const translations = (state = {}, action) => {
// we now have access to language codes from action
const codes = action.languageCodes;
// reducer logic here
}
// custom combine reducers
const rootReducer = (state = {}, action: Action) => {
const languageCodes = state.languages.map(language => language.code);
return {
languages: languages(state.languages, action),
// merge languageCodes with original action object, now you have access in translations reducer
translations: translations(state.translations, {...action, languageCodes})
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment