Disallow missing props validation in a React component definition

27 Views Asked by At

When I create a react project using Vite, I encounter the following error when defining a prop. If I don't have this problem with create React App, why does this error occur? Maybe I have not installed a module?

enter image description here

2

There are 2 best solutions below

0
amirreza mojarad On

check this link, you need to create proptypes for component logrocket

0
Oktay Yuzcan On

This error is from eslint react/prop-types https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/prop-types.md. Seems like creating a react app with vite adds this rule to the eslint config.

You can disable it by oppening .eslintrc.cjs file in the root directory of your app and adding a rule with 0 - "react/prop-types": 0.

Or if it is already included in the rules with value 1 or 2, you can remove that line.