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

266
Visualizações
Redux #subscribe vs. #mapStateToProps

What is the purpose of using subscribe in code like store.subscribe(render)? Doesn't using mapStateToProps and connect already cause the connected component to re-render each time the store's state changes?

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

Quoting the Redux.js page:

Technically you could write the container components by hand using store.subscribe(). We don't advise you to do this because React Redux makes many performance optimizations that are hard to do by hand. For this reason, rather than write container components, we will generate them using the connect() function provided by React Redux,

If you're already using react with redux, you might as well use their package, since it is already optimized.

Also referencing a previous answer: https://stackoverflow.com/a/36214059/3938413

over 4 years ago · Santiago Trujillo Relatório

0

The examples showing store.subscribe(render) are using small code snippets showing you the basic way to hook redux into react.

store.subscribe comes from the redux package. connect comes from the react-redux package and is not a part of redux itself.

The react-redux package uses store.subscribe to hook itself into the redux dispatch cycle. You can then access the redux store by using the connect component enhancer.

Third party libs (or middleware for example) can hook into the store lifecycle via store.subscribe.

over 4 years ago · Santiago Trujillo 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