小编coo*_*per的帖子

TypeError:__ WWEPACK_IMPORTED_MODULE_0_react ___ default.a.createRef不是函数

我是React.js的新手,刚才我正在学习refReact 的概念.他们在V16.3中有新的createRef API.我试图从REACT DOC这样学习这个 -

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
    // …
Run Code Online (Sandbox Code Playgroud)

javascript ref reactjs

6
推荐指数
1
解决办法
9028
查看次数

标签 统计

javascript ×1

reactjs ×1

ref ×1