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

179
Visualizações
react.context usage problem. Cant render from the consumer and pass it as a props

I have a doubt on the usage of react.Context

  1. I got a provider that fetches set of names

  2. I got a consumer a show below

Now i used the consumer component and imported to the component I want to use and wrapped the entire component

But how can i fetch the names and from the consumer and show it in the component where i wanna show and make the names searchable.

If can pass the names as a prop and render the names in the component, I can see it the webpage where i can search the name and it fetches the data from an array.

But when i use the names in this.props and check in the console, it shows undefined and since i cant get an array of names , i cant render them.

Could anyone please guide ?

import React from 'react';
import Context from './Context'; 

export default function(Component) {
    return class extends React.PureComponent{
        render(){
            return(
                <Context.Consumer 
                    children={names=>(
                        <Component {...this.props} names={names} />
                    )}
                />
            )
        }
    }
}


about 4 years ago · Juan Pablo Isaza
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