最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Warning: Failed prop type: Invalid prop `error` of type `string` supplied to `ForwardRef(FormControl)`, expected `b

programmeradmin4浏览0评论

I have a material-ui Textfield ponent in my ReactJS project.

When I run my code, the warning I got in the console is:

Warning: Failed prop type: Invalid prop `error` of type `string` supplied to `ForwardRef(FormControl)`, expected `boolean`.

My ponent code is below. <Field label="First Name*" name="firstName" ponent={InputField} type="text" placeholder="First Name" className="form-control" /> This code works totally fine but the problem is that it gives a warning message in the console.

Warning: Failed prop type: Invalid prop error of type string supplied to ForwardRef(TextField), expected boolean.

Is there any ES6 or any other solution to this?

I have a material-ui Textfield ponent in my ReactJS project.

When I run my code, the warning I got in the console is:

Warning: Failed prop type: Invalid prop `error` of type `string` supplied to `ForwardRef(FormControl)`, expected `boolean`.

My ponent code is below. <Field label="First Name*" name="firstName" ponent={InputField} type="text" placeholder="First Name" className="form-control" /> This code works totally fine but the problem is that it gives a warning message in the console.

Warning: Failed prop type: Invalid prop error of type string supplied to ForwardRef(TextField), expected boolean.

Is there any ES6 or any other solution to this?

Share Improve this question asked Dec 21, 2020 at 6:52 Dhrupad PatelDhrupad Patel 611 gold badge1 silver badge4 bronze badges 1
  • try to pass error={true} – Anh Nhat Tran Commented Dec 21, 2020 at 7:12
Add a ment  | 

3 Answers 3

Reset to default 2

This warning es when you are passing a string value to the boolean property in mui. Like "error", when you give it true it will show an error else will be normal. And if you doing like this error={"some state"} give this a default boolean value otherwise this warning will be displayed.

I had a similar error, I solved changing the default value for a non-empty string

you can set the value to null if the not found or undefined

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论