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

Throwing multiple exceptions when opening View on Android

Open monotv opened this issue 8 years ago • 9 comments

Versions: Android 7

"react": "16.0.0-beta.5",
"react-native": "0.49.3",
"react-native-textinput-effects": "^0.4.1"

First exception:

Exception in native call
com.facebook.react.bridge.JSApplicationIllegalArgumentException: Error while updating property 'backgroundColor' in shadow node of type: AndroidTextInput

Then:

Error while updating prop backgroundColor
com.facebook.react.bridge.UnexpectedNativeTypeException: TypeError: expected dynamic type `int64', but had type `string'

This finally crashes the app:

FATAL EXCEPTION: main
Process: com.xxx, PID: 30962
com.facebook.react.uimanager.IllegalViewOperationException: Trying to add unknown view tag: 94
detail: View tag:100
children(0): [
],
viewsToAdd(1): [
[0,94],
]

Android expects colors as int yet somewhow it is passed as a string it seems.

Looks like there is an issue with Animations in Android: https://github.com/facebook/react-native/issues/13984

monotv avatar Nov 15 '17 01:11 monotv

Thanks for reporting @monotv.

I just tested this on a Android 7 device using the Example project. All text inputs are working fine.

Could you also test it with the Example project so we can make sure this is related with the library. The project is using react-native version 0.50.0 btw.

halilb avatar Nov 19 '17 17:11 halilb

same here. Android 5.0, React Native 0.55.

csotiriou avatar May 14 '18 17:05 csotiriou

Also crashing with unknown view tag exception for me. Android 7.0 RN 0.55

Dantalion avatar Jun 07 '18 09:06 Dantalion

@Dantalion & @csotiriou Still an issue?

vinceprofeta avatar Jul 12 '18 20:07 vinceprofeta

crashing in RN 0.56

winadiw avatar Dec 20 '18 07:12 winadiw

What's the output of crash @winadiw?

halilb avatar Feb 08 '19 11:02 halilb

I encountered this same issue and did some troubleshooting

Primarily it seems to be a user error, in my case I was passing the backgroundColor prop to a hoshi component which does not use the backgroundColor prop, this is because I was trying several different components before settling on the hoshi

Passing the prop backgroundColor to the TextInput react native component causes a crash on android.

Changing the library code fixes this, but is not necessary, like so:

const {
  label,
  style: containerStyle,
  inputStyle,
  labelStyle,
  maskColor,
  borderColor,
  borderHeight,
  inputPadding,
  height: inputHeight,
  backgroundColor,
  ...restOfProps,
} = this.props;
const { width, focusedAnim, value } = this.state;
const flatStyles = StyleSheet.flatten(containerStyle) || {};
const containerWidth = flatStyles.width || width;

return (
  <View
    style={[
      styles.container,
      containerStyle,
      {
        height: inputHeight + inputPadding,
        width: containerWidth,
      },
    ]}
    onLayout={this._onLayout}
  >
    <TextInput
      ref={this.input}
      {...restOfProps}

This adds backgroundColor and ...restOfProps to the initial retrieval of props, then spreads that into the TextInput component instead of ...this.props

I can submit a PR to fix this if you'd like, but it seems likely that the user could simply stop passing backgroundColor in

wizebin avatar Feb 10 '19 18:02 wizebin

Thanks for finding out the problem @wizebin. I'd like to merge that patch if you could create a PR. I agree that it sounds like a user error but I'd like to eliminate it as people keep experiencing that.

halilb avatar Feb 11 '19 10:02 halilb

Any progress on that? )

AfanasievN avatar Mar 12 '19 15:03 AfanasievN