最近一天,我一直在尝试将react-i18next添加到nextJs项目到i18n中,为此,我在他们的仓库中使用了nextJs示例,并试图通过逐步将我的代码添加到他们的代码中来遵循它正常工作,直到我添加了index.js,这是它的代码
`
class Homepage extends Component {
constructor(props) {
super(props);
}
static getInitialProps({ req, store }) {
const token = req && req.cookies && req.cookies.token;
if (token && store) store.dispatch(authUser(token));
}
componentDidMount() {
if (this.props.isAuthenticated) this.props.getUrlsList();
}
shouldComponentUpdate(nextProps) {
return this.props.isAuthenticated !== nextProps.isAuthenticated;
}
render() {
const { appUser } = this.props;
const { isAuthenticated } = this.props;
const needToLogin = !isAuthenticated && <NeedToLogin />;
const table = isAuthenticated && <Table />;
const { t } = this.props;
return (
<BodyWrapper>
<Shortener />
{needToLogin}
{table}
<Features />
<NewsLetter />
<Footer />
<Intercom appID="a8a3gqf7" />
</BodyWrapper>
);
}
}
Homepage.propTypes = {
isAuthenticated: PropTypes.bool.isRequired,
getUrlsList: PropTypes.func.isRequired,
};
const mapStateToProps = ({ auth: { isAuthenticated } }) => ({ isAuthenticated });
const mapDispatchToProps = dispatch => ({
getUrlsList: bindActionCreators(getUrlsList, dispatch),
});
Homepage = withI18next(['home', 'common'])(Homepage);
export default withRedux(initialState , mapStateToProps, mapDispatchToProps)(Homepage);
`
这给了我这个错误
Error: No page context