简体   繁体   English

React-beautiful-dnd - 警告:defaultProps 将被删除

[英]React-beautiful-dnd - warning : defaultProps will be removed

I don't understand this warning in my console.我不明白我的控制台中的这个警告。 Can someone tell me if it's library's problem or if it's an error in my side?有人可以告诉我这是图书馆的问题还是我这边的错误? Warning image警告图片

Here is my code which trigger the warning这是我触发警告的代码

I'm using the version 13.1.1我正在使用版本 13.1.1

<DragDropContext onDragEnd={handleDrop}>
   <Droppable droppableId="list-container" >
      {(providedA: any) => (
         <div {...providedA.droppableProps} ref={providedA.innerRef}>
            {steps.map((step, index) => {
               return <Draggable  key={step.id} draggableId={step.id.toString()} index={index}>
                  {(provided: any) => (
                     <div ref={provided.innerRef} {...provided.dragHandleProps} {...provided.draggableProps}>
                        <div>{step.title}</div>
                     </div>
                   )}
                </Draggable>
              })}
           {providedA.placeholder}
         </div>
      )}
   </Droppable>
</DragDropContext>

Thanks谢谢

I tried to remove the code to find that is the Droppable element which cause the issue.我试图删除代码,发现是导致问题的 Droppable 元素。 I don't find on the github of React-beautiful-dnd any question on this.我在 React-beautiful-dnd 的 github 上没有找到任何关于此的问题。

The warning is caused by the library.警告是由库引起的。 Specifically, react-beautiful-dnd uses an old version of react-redux, which in turn uses the feature mentioned in the message: defaultProps .具体来说,react-beautiful-dnd 使用的是老版本的 react-redux,它又使用了消息中提到的特性: defaultProps

So normally, react-beautiful-dnd would update it's code to use a new version of react-redux, and then you would update to their latest and the problem would go away.所以通常情况下,react-beautiful-dnd 会更新它的代码以使用新版本 react-redux,然后你会更新到他们的最新版本,问题就会消失 go。 However, since react-beautiful-dnd is no longer being developed , it is unlikely that they will do that.但是,由于 react-beautiful-dnd 不再开发,他们不太可能这样做。 This leaves you with a couple options:这给您留下了几个选择:

  1. The code still works, so you could just do nothing.该代码仍然有效,因此您可以什么都不做。 React is warning you that defaultProps will eventually stop working, but we're not there yet. React 警告你 defaultProps最终会停止工作,但我们还没有到那一步。 The earliest possible release that could break the code is react 19.0.0, but there isn't even a timeline for that release yet.可能会破坏代码的最早版本是 React 19.0.0,但该版本甚至还没有时间表。

  2. You could switch to a different library than react-beautiful-dnd.您可以切换到与 react-beautiful-dnd 不同的库。 Maybe something like react-draggable would work for you, though i don't know what your needs are也许像react-draggable这样的东西对你有用,虽然我不知道你的需求是什么

  3. You could fork react-beautiful-dnd and modify their code to fix it.你可以 fork react-beautiful-dnd 并修改他们的代码来修复它。 Then you'd use the forked version of the code instead of the original.然后您将使用代码的分叉版本而不是原始版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM