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

I have a material-ui Textfield ponent in my ReactJS project.When I run my code, the warning I got in t

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

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

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

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

关注微信