Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

_react3.default.createref is not a function.(In '_react2.default.createRef()'_react2.default.createRef is undefined

Unable to login my app via instagram. I am using react-native instagram package, but i am facing the issue as _react3.default.creteRef() is not a function. Refer the attachment

enter image description here Environment:

Packages: (wanted => installed)
  react: 16.2.0 => 16.2.0
  react-native: ^0.53.3 => 0.53.3

Xcode: Xcode 10.1 Build version 10B61
npm: 5.6.0
OS: macOS 10.14.2
Node: 9.4.0
like image 651
sejn Avatar asked Apr 01 '19 05:04

sejn


People also ask

How do you use createRef in react?

Starting from React 16.3, the React API included a createRef() method that can be used for creating refs in much the same way as we did using the callback function. You simply create a ref by calling React. createRef() and assign the resulting ref to an element.

What is createRef in react native?

createRef() is a new API that shipped with React 16.3. You can create a ref by calling React. createRef() and attaching a React element to it using the ref attribute on the element. class Example extends React. Component { constructor(props) { super(props) // Create the ref this.


2 Answers

You are using an old version of react. The createRef API was added in React 16.3.0 and you are using 16.2.0. Release notes here

It seems that this new API is being called from one of your dependencies, as the stacktrace mentions Instagram.js, you need to either update React, or change or downgrade that dependency.

like image 103
sebbab Avatar answered Sep 30 '22 13:09

sebbab


try changing,

ref='ins'

to

ref={instance=>this.instagramRef=instance},

and use refs as this.instagramRef.someFunc() instead of this.refs.ins.someFunc()

and don't forget to set this.instagramRef=null in a constructor.

REMOVE all createRef() if used. and change to this method

like image 43
Jaydeep Galani Avatar answered Sep 30 '22 11:09

Jaydeep Galani