【问题标题】:react-sortable-tree not working on react 17.0.1react-sortable-tree 不适用于反应 17.0.1
【发布时间】:2023-03-05 08:12:01
【问题描述】:

我正在使用 react-sortable-tree 的示例,但它不适用于 react 17.0.1

当我使用 react 16.14.0 时,它没有错误并且工作正常。

错误列表:

  • 无法在未安装的组件上找到节点。 在 findHostInstanceWithWarning
  • 未捕获的类型错误:this.clearMonitorSubscription 不是函数 在 ScrollingComponent.componentWillUnmount
  • 组件出现上述错误:
import React from 'react'
import 'react-sortable-tree/style.css'
import SortableTree from 'react-sortable-tree'
class Areas extends React.Component {
  constructor(props) {
    super(props)

    this.state = {
      treeData: [
        { title: 'Chicken', children: [{ title: 'Egg' }] },
        { title: 'Fish', children: [{ title: 'fingerline' }] }
      ]
    }
  }

  render() {
    return (
      <div style={{ height: 400 }}>
        <SortableTree
          treeData={this.state.treeData}
          onChange={treeData => this.setState({ treeData })}
        />
      </div>
    )
  }
}

【问题讨论】:

    标签: reactjs


    【解决方案1】:

    对我来说,将SortableTree 组件的isVirtualized 属性设置为false 作为临时解决方案(link)。警告:它会在拖动时禁用自动滚动,并滚动到searchFocusOffset

    还有一个使用patch-packagehttps://github.com/frontend-collective/react-sortable-tree/issues/821#issuecomment-766860082的解决方案

    对应问题:https://github.com/frontend-collective/react-sortable-tree/issues/821

    公关观看:https://github.com/frontend-collective/frontend-collective-react-dnd-scrollzone/pull/80

    【讨论】:

    • 为我工作,将isVirtualized 设置为false。谢谢
    • 是的,对我也有用,奇怪的是这个问题从去年就开始了,还没有解决
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-07-24
    • 1970-01-01
    • 1970-01-01
    • 2020-05-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多