Created
February 27, 2018 03:16
-
-
Save ryandrewjohnson/3d70f44108c180640fd08e89f226dbeb 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
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