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

190
Visualizações
Cannot Access props inside function of functional component

I am trying to use props inside function of functional props.

const Inputs = (props) => {
    console.log(props.printFirstArray);
    const FirstInputSet = () => {
        console.log(props.printFirstArray)
   }
}

First console.log is logging the value of printFirstArray, but second console.log inside FirstInputSet() function is not logging anything. Edit: Minimal Code

const Inputs = (props) => {
    const FirstInputSet = () => {
        return (
            <>
                <div className="first input-set">
                    {props.printFirstArray}
                </div>
            </>
        );
    }

    const renderFirstInputSet = () => {
        if (props.firstInputValue)
            return <FirstInputSet />
        else
            return null;
    }

return (
    <>
            {renderFirstInputSet()}
    </>
);
}

Neither props.printFirstArray nor props.printSecondArray is not returning anything

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

From your code, FirstInputSet is a new component and you aren't passing any props.

return <FirstInputSet />

Try to pass your props to the child component but I recommend keeping the child component out of parent component.

OR

If you meant to use FirstInputSet as a function, you can modify the code like below

return FirstInputSet();
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