TypeError: __WEBPACK_IMPORTED_MODULE_0_react___default.a.createRef is not a function

cooper

I am new to React.js and just now i was learning the concept of ref in React. They have new createRef API in V16.3. I was trying to learn this from REACT DOC's like this -

import React from "react";

export class MyComponent extends React.Component {

constructor(props) {
    super(props);
    // create a ref to store the textInput DOM element
    this.textInput = React.createRef();
    this.focusTextInput = this.focusTextInput.bind(this);
}

focusTextInput() {
    // Explicitly focus the text input using the raw DOM API
    // Note: we're accessing "current" to get the DOM node
    this.textInput.current.focus();
}

render() {
    // tell React that we want to associate the <input> ref
    // with the `textInput` that we created in the constructor
    return (
        <div>
            <input
                type="text"
                ref={this.textInput} />

            <input
                type="button"
                value="Focus the text input"
                onClick={this.focusTextInput}
            />
        </div>
    );
}

}

And I was Getting this Error -

TypeError: __WEBPACK_IMPORTED_MODULE_0_react___default.a.createRef is not a function

Here is the screenshot -enter image description here

supra28

You do not seem to have the correct version of react installed

Do this :

npm install --save [email protected] [email protected]

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

TypeError: react__WEBPACK_IMPORTED_MODULE_0___default(...) is not a function

TypeError: react__WEBPACK_IMPORTED_MODULE_0___default.a.createContext is not a function (react frontend, node backend)

Uncaught TypeError: __WEBPACK_IMPORTED_MODULE_0_react___default.a.createContext is not a function

TypeError: styled_components__WEBPACK_IMPORTED_MODULE_0__.default.vedio is not a function on react

React/Firebase error "Uncaught (in promise) TypeError: (0 , _firebase__WEBPACK_IMPORTED_MODULE_1__.default) is not a function"

TypeError: Webpack imported module is not a function

TypeError: react__WEBPACK_IMPORTED_MODULE_6___default.a.lazy is not a function for [email protected]

TypeError: firebase_compat_app__WEBPACK_IMPORTED_MODULE_0__.default.firestore is not a function

Uncaught TypeError: (0 , react_router_dom__WEBPACK_IMPORTED_MODULE_2__.useHistory) is not a function (React.js)

TypeError: _firebase__WEBPACK_IMPORTED_MODULE_3__.default.auth is not a function login from authentication with firebase/react

TypeError: react__WEBPACK_IMPORTED_MODULE_2___default(...) is not a function. How do I solve this?

TypeError: _firebase__WEBPACK_IMPORTED_MODULE_2__.default.collection is not a function

TypeError: _fire__WEBPACK_IMPORTED_MODULE_1__.default.auth is not a function

TypeError: _firebase__WEBPACK_IMPORTED_MODULE_1__.default.collection is not a function

TypeError: __WEBPACK_IMPORTED_MODULE_3__ is not a function

App.js:12 Uncaught TypeError: (0 , react__WEBPACK_IMPORTED_MODULE_1__.useState) is not a function or its return value is not iterable

React.createRef() not works

React createRef current is null

Error in v-on handler (Promise/async): "TypeError: axios__WEBPACK_IMPORTED_MODULE_14___default.a.todo is not a function"

TypeError: styled_components__WEBPACK_IMPORTED_MODULE_1__.default.View is not a function

TypeError: jquery__WEBPACK_IMPORTED_MODULE_1___default(...)(...).select2 is not a function

JQuery in ReactJS: TypeError: jquery__WEBPACK_IMPORTED_MODULE_18___default(...)(...).sortable is not a function

TypeError: _firebase_firebase__WEBPACK_IMPORTED_MODULE_8__.default.auth is not a function

Uncaught (in promise): TypeError: firebase_compat_app__WEBPACK_IMPORTED_MODULE_1__.default.storage is not a function

TypeError: firebase_compat_app__WEBPACK_IMPORTED_MODULE_4__.default.auth is not a function

TypeError: axios__WEBPACK_IMPORTED_MODULE_1___default.a.get(...).than is not a function

TypeError: _firebase_config__WEBPACK_IMPORTED_MODULE_2__.default.auth is not a function

Webpack compile error: TypeError: __WEBPACK_IMPORTED_MODULE_1__ … is not a function

Uncaught TypeError: firebase_app__WEBPACK_IMPORTED_MODULE_0__.firestore is not a function in Vue js