React-native: SectionList with jest: nodeHandle.getHostNode is not a function

Created on 13 Jul 2017  路  4Comments  路  Source: facebook/react-native

I have a <SectionList> element:

<SectionList
  style={styles.listView}
  sections={this.props.data}
  renderItem={this.renderRow}
  renderSectionHeader={this.renderSectionHeader}
/>

When running jest, it shows an error:

    TypeError: nodeHandle.getHostNode is not a function

      at Object.findNumericNodeHandleStack [as findNodeHandle] (node_modules/react-native/Libraries/Renderer/ReactNativeStack-dev.js:2348:76)
      at AnimatedProps.__connectAnimatedView (node_modules/react-native/Libraries/Animated/src/AnimatedImplementation.js:1707:31)
      at AnimatedProps.__makeNative (node_modules/react-native/Libraries/Animated/src/AnimatedImplementation.js:1690:6)
      at AnimatedStyle.__makeNative (node_modules/react-native/Libraries/Animated/src/AnimatedImplementation.js:159:7)
      at AnimatedStyle.__makeNative (node_modules/react-native/Libraries/Animated/src/AnimatedImplementation.js:1577:109)
      at AnimatedTransform.__makeNative (node_modules/react-native/Libraries/Animated/src/AnimatedImplementation.js:159:7)
      at AnimatedTransform.__makeNative (node_modules/react-native/Libraries/Animated/src/AnimatedImplementation.js:1403:117)
      at AnimatedInterpolation.__makeNative (node_modules/react-native/Libraries/Animated/src/AnimatedImplementation.js:159:7)
      at AnimatedValue.__makeNative (node_modules/react-native/Libraries/Animated/src/AnimatedImplementation.js:159:7)
      at AnimatedValue.__makeNative (node_modules/react-native/Libraries/Animated/src/AnimatedImplementation.js:730:109)

How do I deal with this? Or is it just a bug?

Environment

  1. react-native -v: 0.46.2 (with jest 20.0.4)
  2. node -v: 7.8.0
  3. npm -v: 5.2.0
  4. yarn --version (if you use Yarn): 0.22.0
Locked

Most helpful comment

This feels like a legitimate bug in react-native. Not necessarily something for StackOverflow.

For clarity, I am also getting this error, and the error is certainly occurring in react-native's code, not userland.

All 4 comments

This issue looks like a question that would be best asked on StackOverflow.

StackOverflow is amazing for Q&A: it has a reputation system, voting, the ability to mark a question as answered. Because of the reputation system it is likely the community will see and answer your question there. This also helps us use the GitHub bug tracker for bugs only.

Will close this as this is really a question that should be asked on StackOverflow.

This feels like a legitimate bug in react-native. Not necessarily something for StackOverflow.

For clarity, I am also getting this error, and the error is certainly occurring in react-native's code, not userland.

For workaround, adding the following mock code before running jest:

jest.mock('VirtualizedList', () => {
  const RealComponent = require.requireActual('VirtualizedList');
  const React = require('React');
  class VirtualizedList extends React.Component {
    render() {
      delete this.props.getScrollableNode;
      return React.createElement('VirtualizedList', this.props, this.props.children);
    }
  }
  VirtualizedList.propTypes = RealComponent.propTypes;
  return VirtualizedList;
});

VirtualizedList has a method getScrollableNode which triggers this issue.

Not disputing it's a bug. Feel free to submit a new issue, but please make sure to follow the issue template.

Was this page helpful?
0 / 5 - 0 ratings