Created
April 7, 2018 02:49
-
-
Save ryandrewjohnson/3bf20224e12adbfc7ba9af66b52e885f to your computer and use it in GitHub Desktop.
translate function with connect
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
import { getTranslate, getActiveLanguage } from 'react-localize-redux'; | |
const Greeting = ({ translate, currentLanguage }) => ( | |
<div> | |
<h1>{ translate('greeting') }</h1> | |
<button>{ translate('farewell') }</button> | |
</div> | |
); | |
const mapStateToProps = state => ({ | |
translate: getTranslate(state.locale), | |
currentLanguage: getActiveLanguage(state.locale).code | |
}); | |
export default connect(mapStateToProps)(Greeting); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment