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
3 Answers
Reset to default 2This 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条)