*以下是安装包时的完整错误堆栈消息
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
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 [email protected]
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和droppable(完整组件Main)的完整代码。
这是使用包中的dragdropcontext和droppable(完整组件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)
我认为您遇到了缓存问题,因为它在我的机器上运行良好,没有错误。删除node_modules,更新npmnpm -g install npm
并重新安装一切。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)