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

169
Visualizações
The problem with passing callback functions, writes an error props.me is not a function, I can only show part of the code

There is a parent and a child (component) I want to get the values ​​from the child to the parent, I throw the functions themselves into the component, in the child I wrote the return target of the value from the input

parent

const [m, setM] = useState("")
    const me = (m) => {
        setM(m)
        console.log(m)
    }

    const [dey, setD] = useState("")
    const de = (dey) => {
        setD(dey)
    }

    const [y, setY] = useState("")
    const ye = (y) => {
        setY(y)
    }

its companent connect in jsx

<CustomSelect
    className="flex-1"
    btnClass="inp"
    checkedOpt={dey}
    options={d}
    de={de}
/>
<CustomSelect
    className="flex-1 ms-2 ms-xxl-4"
    btnClass="inp"
    checkedOpt={m}
    options={month}
    me={me}
/>
<CustomSelect
    className="flex-1 ms-2 ms-xxl-4"
    btnClass="inp"
    checkedOpt={y}
    options={years}
    ye={ye}
/>

child

 const handleChange = (e) => {
        props.de(e.target.value);
        props.me(e.target.value);
        props.ye(e.target.value);
    }

jsx

<input
    type="radio"
    name="type"
    value={item}
    checked={(item === props.checkedOpt)}
    onChange={handleChange}
/>
about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Since the props.me is not passed to every component, you just have to check if it's passed as function :

 const handleChange = (e) => {
        props.de?.(e.target.value);
        props.me?.(e.target.value);
        props.ye?.(e.target.value);
    }
about 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