小编Nir*_*ish的帖子

警告:在 StrictMode 中不推荐使用 findDOMNode。findDOMNode 传递了一个在 StrictMode 内的 Transition 实例

我正在尝试使用一个函数作为组件内的道具,而这个组件是另一个组件的子组件。但该功能不起作用。?我能知道为什么吗。这是我在控制台中收到的警告。

警告:在 StrictMode 中不推荐使用 findDOMNode。findDOMNode 传递了一个位于 StrictMode 内的 Transition 实例。相反,直接向要引用的元素添加 ref

这是我的代码

class Todo extends Component {
  state = {
    show: false,
    editTodo: {
      id: "",
      title: "",
      isCompleted: false
    }
  }
  handleClose = () => {
    this.setState({ show: false })
  }
  handleShow = () => {
    this.setState({ show: true })
  }
  getStyle () {
    return {
      background: '#f4f4f4',
      padding: '10px',
      borderBottom: '1px #ccc dotted',
      textDecoration: this.props.todo.isCompleted ? 'line-through'
        : 'none'
    }
  }
  //this method checks for changes in the …
Run Code Online (Sandbox Code Playgroud)

javascript strict-mode reactjs react-component react-state

88
推荐指数
7
解决办法
18万
查看次数