Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

171
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda