react-native icon indicating copy to clipboard operation
react-native copied to clipboard

[Android] Crashes when secureTextEntry is not a boolean

Open mayuelei66 opened this issue 11 years ago • 4 comments

I found a interesting thing.When I use the TextInput with secureTextEntry property.If both Android and IOS works fine.But When I use it like this the Android version just go wrong.But the IOS version works fine. image.

mayuelei66 avatar Sep 21 '15 07:09 mayuelei66

Thanks for reporting. You should use secureTextEntry={true} as that property is defined as boolean here: https://github.com/facebook/react-native/blob/master/Libraries/Components/TextInput/TextInput.js#L232

It's not intended that it works on iOS passed as a string. This is related to some implicit casting and I'm afraid that secureTextEntru='false' may also be interpreted on iOS as true.

This problem should've been caught by flow, not sure if you're using flow by any chance?

cc: @sahrens

kmagiera avatar Sep 21 '15 08:09 kmagiera

As a shortcut, you could just do secureTextEntry without the ={true}. Only if you want to disable it do you need to specify the boolean property :) But yeah, this probably shouldn't cause a crash

brentvatne avatar Sep 22 '15 09:09 brentvatne

IMO it should definitely be a red-box, in that case it's even very clear one. Property is of type "bool" and you're providing a "string".

I think that we expect RN to give you a similar error when you set string as value for alpha or translationX, that's a very similar case. I believe we should instead add some type-checking to iOS native code.

kmagiera avatar Sep 22 '15 10:09 kmagiera

We shouldn't accept strings as booleans, created https://github.com/facebook/react-native/issues/3003 to make this consistent on iOS and Android.

mkonicek avatar Sep 24 '15 13:09 mkonicek