React Native ERROR Warning: Failed prop type: Invalid prop placeholder of type object supplied to TextInput expected string

Created At: 2024-04-26 05:14:20 Updated At: 2024-04-26 09:31:57

React native error 

 ERROR  Warning: Failed prop type: Invalid prop `placeholder` of type `object` supplied to `TextInput`, expected `string`

You encounter this error mostly in form submission in React native. At the first glance, the error is not obvious, it's just saying an invalid prop placeholder is given to an in input TextInput. It also said that, it has expected string but found something else.

After debugging a lot, I found that issue was regarding wrong and mismatch of state variables in React native.

You know that in React Native state variables defined using useState() must be unique in terms of variable of gettter and setter.

In my case, I was using the same state variables in two different places but with two different purposes. 

In one of the places, I was supposed to use useState() variables for filling in the text field as string. This was the correct usage, but the same state variables I also used for context.

This was the culprit and caused the above the above error. So with react native make sure you use the right state variable(useState) and context(useContext) correctly.

React Native Multi Vendor App

Comment

Add Reviews