React-i18next: How to use this library when using redux?

Created on 29 Apr 2019  路  5Comments  路  Source: i18next/react-i18next

my page is connected to a redux store, like so:

export default withRouter(
    connect(
        mapStateToProps,
        { postResendEmailConfirmation, getEmailVerificationCheck, getPermissions }
    )(Welcome))
);

After following a tutorial and adding the configuration, I have imported:

 import { withNamespaces } from 'react-i18next';

but I don't how how to connect the two. I did this:

export default withRouter(
    connect(
        mapStateToProps,
        { postResendEmailConfirmation, getEmailVerificationCheck, getPermissions }
    )(withNamespaces('translations')(Welcome))
);

but the error is:

Component.js:144 [React-imported-component] TypeError: (0 , _reactI18next.withNamespaces) is not a function

Most helpful comment

@jamuhl the version is: "react-i18next": "^10.9.0".

And now it looks like this:
export default withRouter(
connect(
mapStateToProps,
{ postResendEmailConfirmation, getEmailVerificationCheck, getPermissions }
)(withTranslation('translations'))(Welcome)
);
However, my error is now : [React-imported-component] TypeError: Cannot set property 'props' of undefined

You have an issue with your parenthesis: (withTranslation('translations'))(Welcome) should be (withTranslation('translations')(Welcome))

All 5 comments

what version of react-i18next? -> latest would use withTranslation -> https://react.i18next.com/latest/migrating-v9-to-v10#components-v9-greater-than-v10

@jamuhl the version is: "react-i18next": "^10.9.0".

And now it looks like this:
export default withRouter(
connect(
mapStateToProps,
{ postResendEmailConfirmation, getEmailVerificationCheck, getPermissions }
)(withTranslation('translations'))(Welcome)
);
However, my error is now : [React-imported-component] TypeError: Cannot set property 'props' of undefined

Can't reproduce this...must be related to your code...

@jamuhl the version is: "react-i18next": "^10.9.0".

And now it looks like this:
export default withRouter(
connect(
mapStateToProps,
{ postResendEmailConfirmation, getEmailVerificationCheck, getPermissions }
)(withTranslation('translations'))(Welcome)
);
However, my error is now : [React-imported-component] TypeError: Cannot set property 'props' of undefined

You have an issue with your parenthesis: (withTranslation('translations'))(Welcome) should be (withTranslation('translations')(Welcome))

@T0nio wow...good catch on that one...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MohammedAl-Mahdawi picture MohammedAl-Mahdawi  路  4Comments

Jessidhia picture Jessidhia  路  4Comments

ChCosmin picture ChCosmin  路  4Comments

dawsbot picture dawsbot  路  4Comments

leandrocamacho picture leandrocamacho  路  4Comments