更改传入道具不重新呈现 react-sortable-hoc 列表

Changed incoming props not rerendering react-sortable-hoc list

我目前正在尝试将 react-sortable-hoc 添加到列表组件中,当我通过 props 更改传入的项目列表时,我 运行 遇到了一些错误。例如:如果我向数组添加一个项目,并检查列表的传入道具,可排序组件中的道具正在改变(我在列表组件道具中看到新项目),但我无法获得要重新渲染的组件。我已经尝试过 shouldComponentUpdate、getDerivedStateFromProps、使用 PureComponent 而不是 Component、forceUpdate、hookify 整个事情并为 props 的任何更改设置 useEffect,没有任何东西导致重新渲染,我知道新列表正在到达组件。

是否有其他人遇到同样的问题或是否有人找到解决方法?

以下是我的设置方式 props/state,以及我如何知道道具正在发生变化:

class MobileListItems extends Component {

  state = {
    items: this.props.listItems,
  }

.
.
.

  render() {

    console.log('this.props.listItems', this.props.listItems)
    console.log('this.state.items', this.state.items)

在我对一些东西进行排序并尝试添加另一个项目之后,this.props.listItems 增加了 1,但是无论我尝试了上面的哪种方法都没有重新渲染。

哎呀雏菊!不要将你的道具复制到状态中,你们大家。不要像我一样!

删除状态管理并将其转换为函数修复了我遇到的所有错误。