react-native: null is not an object (evaluating 'this._component.getScrollableNode')

Description

http://crashes.to/s/280c411449d

Fatal Exception: com.facebook.react.common.JavascriptException: null is not an object (evaluating 'this._component.getScrollableNode'), stack:
value@297:1662
value@297:1031
unmountComponent@144:3508
unmountComponent@134:444
unmountComponent@144:3555
unmountComponent@134:444
unmountChildren@142:830
unmountChildren@139:2252
unmountComponent@119:361
unmountComponent@134:444
unmountComponent@144:3555
unmountComponent@134:444
unmountChildren@142:830
unmountChildren@139:2252
unmountComponent@119:361
unmountComponent@134:444
unmountChildren@142:830
unmountChildren@139:2252
unmountComponent@119:361
unmountComponent@134:444
unmountChildren@142:830
unmountChildren@139:2252
unmountComponent@119:361
unmountComponent@134:444
unmountComponent@144:3555
unmountComponent@134:444
unmountComponent@144:3555
unmountComponent@134:444
unmountComponent@144:3555
unmountComponent@134:444
unmountComponent@144:3555
unmountComponent@134:444
unmountComponent@144:3555
unmountComponent@134:444
unmountChildren@142:830
unmountChildren@139:2252
unmountComponent@119:361
unmountComponent@134:444
unmountChildren@142:830
unmountChildren@139:2252
unmountComponent@119:361
unmountComponent@134:444
unmountComponent@144:3555
unmountComponent@134:444
unmountComponent@144:3555
unmountComponent@134:444
unmountComponentFromNode@234:1542
unmountComponentAtNode@234:1438
unmountComponentAtNodeAndRemoveContainer@234:1196
unmountApplicationComponentAtRootTag@328:1109
value@58:2827
<unknown>@58:1062
d@58:130
value@58:1034

       at com.facebook.react.modules.core.ExceptionsManagerModule.showOrThrowError(ExceptionsManagerModule.java:97)
       at com.facebook.react.modules.core.ExceptionsManagerModule.reportFatalException(ExceptionsManagerModule.java:81)
       at java.lang.reflect.Method.invokeNative(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:525)
       at com.facebook.react.bridge.BaseJavaModule$JavaMethod.invoke(BaseJavaModule.java:318)
       at com.facebook.react.cxxbridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:158)
       at com.facebook.react.bridge.queue.NativeRunnable.run(NativeRunnable.java)
       at android.os.Handler.handleCallback(Handler.java:730)
       at android.os.Handler.dispatchMessage(Handler.java:92)
       at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
       at android.os.Looper.loop(Looper.java:137)
       at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:196)
       at java.lang.Thread.run(Thread.java:841)

Additional Information

  • React Native version: RN 0.36
  • Platform: Android
  • Operating System: MacOS

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 41
  • Comments: 61 (22 by maintainers)

Commits related to this issue

Most upvoted comments

In my case what haikyuu said solved it. A had component that used ART in the background (a spinner), written stateless.

const Whatever = (props) => { // ..... bla bla

I changed it to a normal component: class Whatever extends React.Component { // ..... bla bla

and I never saw the error ever since.

I think the issue comes from Animated trying to attach ref to a stateless component. And stateless components cannot have refs.

Using class to create the component does fix the issue.

Here is a react-native project to reproduce it.

This was also asked in stackoverflow

Hopefully this helps someone!

I narrowed it down in my app to react-navigation

When null’ing out the route stack and pushing a new route (without a stack in between or resetting correctly) it will throw this when you hit the back button. Here’s the change I made:

image

Still exists.

"react": "16.0.0-alpha.12",
"react-native": "0.47.1",

EDIT: I have made a custom Card element, simple file nothing fancy (40 lines) and this error occurs when import it in some other JS file. Funny part is that It doesn’t occur when importing but occurs when that component is used.

import { Card } from './Card';

No error ^

<Card>
</Card>

error.

I am not using any Animation.

Edit 2: Solved it:

how?

I was doing export default Card (my bad) changing it to export {Card} fixed it.

Hope it helps someone.

@yelongfei2008 I monkey patched my local react native codebase to guard against this._component being null in this._detachNativeEvents and this._attachNativeEvents. Works fine now, but looking forward to a proper solution to this.

I’ve ran into this a few times before reading @haikyuu comment. The exact issue I was seeing involves TouchableHighlight (possibly also TouchableOpacity). I got this error when using a Component class, a stateless functional component, and a Text component as a child. Simple fix:

<TouchableHighlight>
  <MyComponent/>
</TouchableHighlight>

change to:

<TouchableHighlight>
  <View>
    <MyComponent/>
  </View>
</TouchableHighlight>

I had this problem because the child of TouchableHighlight was no a View but a Text. Making a View the direct child of TouchableHighlight solved my problem

These are my dependencies

“react”: “16.0.0-alpha.3”, “react-native”: “0.43.2”,

I’m getting this error as well, only seems to be happening on Android for me, and I’ve seen it happen on Android 4.4.2, 6.0 and 7.0.

I’m using ART for a component in my app also, but my component that uses ART is already a normal component (extends React.Component). Not sure if maybe one of its child components is a stateless component and that’s causing the issue, like @SudoPlz suggests? Also not sure if this error really gets triggered by anything relating to this component that uses ART.

My dependencies are:

"react": "~15.4.0",
"react-native": "0.41.2",

My app is suffering from this, but only when I deploy through iTunesConnect / TestFlight. So far I’ve not been able to reproduce in dev mode. And it doesn’t happen consistently unfortunately.

I’ve searched my codebase for both componentWillUpdate and componentWillReceiveProps and they don’t appear. Sorry I can’t be of more help