Skip to content Skip to sidebar Skip to footer

React' Findnodehandle Method Stopped Working

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

Solution 1:

Now the function may be used without object:

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

And call it directly:

findNodeHandle(this.refs[refName])

Solution 2:

You have to import ReactNative as well.

importReactNativefrom'react-native';
...
ReactNative.findNodeHandle(...)

Solution 3:

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

varRCTUIManager = require('NativeModules').UIManager;

var view = this.refs['yourRef']; // Where view is a ref obtained through <View ref='ref'/>RCTUIManager.measure(findNodeHandle(view), (fx, fy, width, height, px, py) => {
  console.log('Component width is: ' + width)
  console.log('Component height is: ' + height)
  console.log('X offset to frame: ' + fx)
  console.log('Y offset to frame: ' + fy)
  console.log('X offset to page: ' + px)
  console.log('Y offset to page: ' + py)
})

Post a Comment for "React' Findnodehandle Method Stopped Working"