Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

196
Vistas
missing in props validation react/prop-types

The solutions provided when doing my research are based on React class and not React function and I'm just a newbie in React.

From the parent component I'm calling the child component and passing the values as 'data'. In the child component I'm retrieving the value using props.

ParentComponent.js

<ChildComponent data={1}/>

ChildComponent.js

function ChildComponent(props) {
    const { data } = props.data;
    ...
}

The above gives me the following error message:

src\components\ChildComponent\ChildComponent.js Line 5:11: 'data.data' is missing in props validation react/prop-types Line 5:29: 'data' is missing in props validation react/prop-types

Search for the keywords to learn more about each error.

about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

props is collecting all attributes which you pass to ChildComponent

Your data should be like this

function ChildComponent(props) {
    const { data } = props; //object destructuring
    ...
}

Or like this

function ChildComponent(props) {
    const data = props.data //access data directly and assign a new variable
    ...
}
about 4 years ago · Juan Pablo Isaza Denunciar

0

@Denno and @Nick Vu is correct but there might be something else you'll have to add to your child component just before the export.

ChildComponent.propTypes = {
  data: PropTypes.object
};

and add import

import PropTypes from "prop-types";

and change this

function ChildComponent(props) {
    const { data } = props.data;
    ...
}

to

function ChildComponent(props) {
    const data = props.data;
    ...
}
about 4 years ago · Juan Pablo Isaza Denunciar

0

you should learn something about ES6(Destructuring Assignment), if you want to konw this meaning about const { data } = props.data

or simple chang code to this

function ChildComponent(props) {
    const data = props.data 
}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda