Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

172
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda