Skip to content

Instantly share code, notes, and snippets.

@giautm
Last active December 23, 2017 05:12
Show Gist options
  • Save giautm/d971c227e788396e254d4b78447e3249 to your computer and use it in GitHub Desktop.
Save giautm/d971c227e788396e254d4b78447e3249 to your computer and use it in GitHub Desktop.
Bug
import React from 'react';
import Link from 'next/link';
import { translate } from 'react-i18next';
import i18n from '../i18n';
import Frontend from '../components/frontend/Frontend/Frontend';
class Home extends React.Component {
render() {
return (
<Frontend>
{this.props.t('welcome')}
</Frontend>
);
}
}
const Extended = translate(['home', 'common'], {
i18n,
wait: process.browser,
})(Home);
// Passing down initial translations
// use req.i18n instance on serverside to avoid overlapping requests set the language wrong
Extended.getInitialProps = async ({ req }) => {
if (req && !process.browser) return i18n.getInitialProps(req, ['home', 'common']);
return {};
};
export default Extended;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment