Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

166
Views
Exporting component using i18n's useTranslation and redux's connect HOCs

My App has used Redux for a long time, with the component exports looking like

export default connect(mapStateToProps, mapDispatchToProps)(MyComponent);

I'm now introducing i18n's translation library and would like to use the HOC that is included with the useTranslation.

I've attempted a few different ways and seen that Redux has a connect piece of functionality that is supposed to combine HOCs if I understand correctly, however I cannot get this to work.

export default connect(useTranslation(), connect(mapStateToProps, mapDispatchToProps))(MyComponent);

When I load the browser I am shown:

Uncaught ReferenceError: process is not defined

Am I missing something here?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

useTranslation is not a HOC, you want withTranslation. That will look like this:

export default connect(mapStateToProps, mapDispatchToProps)(withTranslation()(MyComponent));

Or, since the order doesn't matter:

export default withTranslation()(connect(mapStateToProps, mapDispatchToProps)(MyComponent));

Nesting multiple HOCs can be hard to read, so it may be easier to use a compose utility function. Redux even includes one:

import { compose, connect } from 'redux';

//...

export default compose(
  connect(mapStateToProps, mapDispatchToProps),
  withTranslation()
)(MyComponent);
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!