*以下是安装程序包时的完整错误堆栈消息
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: freeboard@0.1.0
npm ERR! Found: react@17.0.1
npm ERR! node_modules/react
npm ERR! react@"^17.0.1" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.8.5" from react-beautiful-dnd@13.0.0
npm ERR! node_modules/react-beautiful-dnd
npm ERR! react-beautiful-dnd@"^13.0.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
以下是使用dragdropcontext和dropable from the package的完整代码,即完整组件Main。以下是使用dragdropcontext和dropable from the package的完整代码,即完整组件Main。
import { connect } from "react-redux"
import { DragDropContext, Droppable } from 'react-beautiful-dnd';
import SingleTask from "../SingleTask/SingleTask"
import "./Main.css"
const Main = (props) => {
const [tasks, setTasks] = useState([])
useEffect(() => {
setTasks(...[props.tasks])
},[props])
return (
<>
<DragDropContext>
<Droppable droppableId="Box1">
{(provided) => (
<div {...provided.droppableProps} ref={provided.innerRef}>
{provided.placeholder}
<div className="main-board">
<h2>FreeBoard</h2>
{ tasks && tasks.map((task, index) => {
return (
<div className="tasks-list" key={index}>
<SingleTask taskName={task} indexCount={index}/>
</div>
)
}) }
</div>
</div>
)}
</Droppable>
</DragDropContext>
</>
)
}
const mapStateToProps = state => {
return state
}
export default connect(mapStateToProps)(Main)
3条答案
按热度按时间4ktjp1zp1#
我认为你有一个缓存问题,因为它在我的机器上工作得很好,没有错误。删除node_modules,更新npm
npm -g install npm
,然后重新安装所有的东西。dced5bon2#
我也遇到了同样的问题。试着降级react版本。我从v18.1.0改到了v17.0.2。这很有帮助
6qqygrtg3#
作为react-beautiful-dnd的一种替代方法,请尝试hello pangea dnd
只需将react-beauty-dnd导入行替换为: