Skip to content

Instantly share code, notes, and snippets.

@ryandrewjohnson
Created April 7, 2018 02:49
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/3bf20224e12adbfc7ba9af66b52e885f to your computer and use it in GitHub Desktop.
Save ryandrewjohnson/3bf20224e12adbfc7ba9af66b52e885f to your computer and use it in GitHub Desktop.
translate function with connect
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