missing in props validation react/prop-types

Kestal

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.

Navneil Naicker

@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;
    ...
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

React eslint error missing in props validation

React Navigation 'navigation' is missing in props validation

ESLint: '.map is missing in props validation' (eslint react/prop-types) in Typescript React

Props is missing from props validation

Flow is missing props validation when setting default values on an object

VueJS - Object Props validation

React-navigation, tintColor is missing in props validation

Eslint - 'match' is missing in props validation (react/prop-types)

Line 5: 'tags' is missing in props validation react/prop-types

ESlint complains about this.props.handleSubmit missing in prop validation

ESLint missing props validation in Class Component

Dispatch action is missing in props validation [react/prop-types]

Props in functional component are missing in props validation

React Redux missing in props validation and recommended pattern for initialising container from an external API using redux-observable

useEffect missing dependencies 'props'

is missing in props validation React JS

'classes' is missing in props validation - Linting

Why, even after specifying a type parameter for a React component, the linter still complains about '<property>' missing in props validation?

eslint+ flow : 'attribute' is missing in props validation (Object with identifier)

data.site.siteMetadata.description is missing props validation - gatsby and graphQl

ESLint error: "Missing props in validation" in React ( Replacing it by PropTypes.checkPropTypes does not fix it )?

How to solve ESLint is missing in props validation in React?

'setLoading' is missing in props validation

'match.params.id' is missing in props validation

'children' is missing in props validation react/prop-types

Line 4:27: 'component' is missing in props validation react/prop-types

Missing in props validation (props-types)

ESLint `prop is missing in props validation` but it's there

Parameter is missing in props validation