reactjs - React "prop-types" not showing warning validation messages on bowser console - Stack Overflow

I have tried the following, expecting to have some kind of validation warning msg on the Chrome console

I have tried the following, expecting to have some kind of validation warning msg on the Chrome console, but nothing happens (console all crear) when not setting the "title" variable on the main.jsx FirstApp component

main.jsx

import React from 'react';
import ReactDOM from 'react-dom/client';
import {FirstApp} from './FirstApp';
ReactDOM.createRoot( document.getElementById('root') ).render(
    <React.StrictMode>
        <FirstApp/>
    </React.StrictMode>
);

FirstApp.jsx

import PropTypes from 'prop-types';
export const FirstApp = ({title}) => {
  return (
    <>
        <h1>{title}</h1>
        <h2>Hello World</h2>
    </>
  )
}
FirstApp.propTypes = {
  title: PropTypes.string.isRequired
}

I have checked the browser settings, reset to defaults with no result. The component is working as I am able to see Hello World. I'm using Vite and running: npm run dev. Here below my package.json dependencies:

"prop-types": "^15.8.1",
"react": "^19.0.0",
"react-dom": "^19.0.0",

I have tried the following, expecting to have some kind of validation warning msg on the Chrome console, but nothing happens (console all crear) when not setting the "title" variable on the main.jsx FirstApp component

main.jsx

import React from 'react';
import ReactDOM from 'react-dom/client';
import {FirstApp} from './FirstApp';
ReactDOM.createRoot( document.getElementById('root') ).render(
    <React.StrictMode>
        <FirstApp/>
    </React.StrictMode>
);

FirstApp.jsx

import PropTypes from 'prop-types';
export const FirstApp = ({title}) => {
  return (
    <>
        <h1>{title}</h1>
        <h2>Hello World</h2>
    </>
  )
}
FirstApp.propTypes = {
  title: PropTypes.string.isRequired
}

I have checked the browser settings, reset to defaults with no result. The component is working as I am able to see Hello World. I'm using Vite and running: npm run dev. Here below my package.json dependencies:

"prop-types": "^15.8.1",
"react": "^19.0.0",
"react-dom": "^19.0.0",
Share Improve this question edited Feb 23 at 11:12 Antonio Retamosa asked Feb 23 at 10:53 Antonio RetamosaAntonio Retamosa 11 bronze badge
Add a comment  | 

1 Answer 1

Reset to default -1

I jave just found prop-types are no longer validated in React 19.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745157401a4614208.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信