React' findNodeHandle method stopped working

Ivan Chernykh picture Ivan Chernykh · May 12, 2016 · Viewed 16.3k times · Source

After upgrade to 0.26.0-rc version, this line:

React.findNodeHandle(this.refs.myRef)

Throws this error message:

Unhandled JS Exception: _react2.default.findNodeHandle is not a function.

I'm importing React with this:

import React from 'react';

Docs still say: "As always, to obtain a native node handle for a component, you can use React.findNodeHandle(component)."

Answer

igor picture igor · Jun 13, 2016

Now the function may be used without object:

import {
  ...
  findNodeHandle,
  ...
} from 'react-native';

And call it directly:

findNodeHandle(this.refs[refName])