Daniel Jackson
Daniel Jackson

Reputation: 97

React-native TextInput crash

Ok... So here is the probelem.

I am new to react-native, so I'm probably missing something simple, but whenever I run the slightly modified Hello World app, it crashes with an error reading

Attempt to invoke virtual method 'android.graphics.drawable.Drawable android.graphics.drawable.Drawable$ConstantState.newDrawable(android.content.res.Resources)' on a null object reference

Here is the source causing this crash for me

import React, { Component } from 'react';
import { TextInput, Text, View } from 'react-native';

export default class App extends Component {
  render() {
    return (
      <View>
        <Text>Hello world!</Text>
        <TextInput></TextInput>
      </View>
    );
  }
}

EDIT: Ok, so I updated npm re-installed the project and it still crashed. However, after I restarted Expo on my phone, it started working again. I'm not sure what happened but it appears it may have been an issue with my slightly old npm version and then Expo hung onto that error until I forced it to restart.

Just an idea, but it's the best I have. I'll update if things change.

Thanks everyone!

Upvotes: 1

Views: 5539

Answers (3)

Oliver Kucharzewski
Oliver Kucharzewski

Reputation: 2665

The following resolved it for me:

  1. Reset packager and clear its cache. (R)

  2. Clear cache on your Expo app too.

  3. Restart app.

Upvotes: 0

Kosalram Ramakrishnan
Kosalram Ramakrishnan

Reputation: 818

The TextInput crash was reported in the react-native version 0.56 and it was resolved in react-native version 0.57

Please refer the changelog of react-native 0.57 in the following link.

https://github.com/react-native-community/react-native-releases/blob/master/CHANGELOG.md#057

I'm suggesting to upgrade your react-native versions.

Upvotes: 2

Julio Truzzi
Julio Truzzi

Reputation: 532

Your issue may be due to the TextInput not having an appropriate closing tag.

<TextInput />

Upvotes: 0

Related Questions