Warning: Failed context type: The context `dragDropManager` is marked as required in `DropTarget(ScheduleCell)`, but its value is `undefined`.
See original GitHub issuewith the following…
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import ShiftItem from './ShiftItem';
import { DropTarget } from 'react-dnd';
const cellTarget = {
drop(props, monitor, component) {
return Object.assign(component.state, props);
},
canDrop(props) {
return true;
},
};
const collect = (connect, monitor) => {
return {
connectDropTarget: connect.dropTarget(),
isOver: monitor.isOver(),
};
};
export class ScheduleCell extends Component {
static propTypes = {
shifts: PropTypes.object,
positions: PropTypes.object,
startOfWeek: PropTypes.object, // Date
};
renderShifts() {
return this.props.shifts.map(shift => {
const position = shift.position_id ? this.props.positions.get(shift.position_id) : null;
return (
<ShiftItem
key={ `shift-${shift.id}` }
shift={ shift }
position={ position }
/>
);
}).toArray();
}
render() {
return (
<div className="schedule-row-cell">
<div className="shift-holder">
{ this.renderShifts() }
</div>
</div>
);
}
}
export default DropTarget('shift', cellTarget, collect)(ScheduleCell);
am i missing something simple?
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
The context `router` is marked as required in `Link`, but its ...
Warning : Failed context type: The context `router` is marked as required in `Link`, but its value is `undefined`. and. Uncaught TypeError: ...
Read more >Troubleshooting - React DnD - GitHub Pages
Troubleshooting. This page is dedicated to the problems you might bump into while using React DnD. Could not find the drag and drop...
Read more >react-sortable-tree - Bountysource
Drag-and-drop sortable representation of hierarchical data ... type: The prop `"aria-label"` is marked as required in `Grid`, but its value is `undefined`.
Read more >zan-design出现react dnd报错- SegmentFault 思否
Warning : Failed context type: The context `dragDropManager` is marked as required in `DropTarget(DragSource(EditorCardItem))`, but its value ...
Read more >Draggable elements with React-dnd - The Widlarz Group
I recently had a chance to work with draggable HTML elements and I'd ... Having such a context setup, you can access values...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I had to do something like this
export default DragDropContext(HTML5Backend)(Layout);
on my layout that was wrapping the components i wanted to drag and drop on, since we use it many places i just did it on my entire applications layout component. @willluckYou can also write a function in separate JS file as below
const dndContext = DragDropContext(HTML5Backend); export function getDragDropContext(Component) { return dndContext(Component); }
and then use this as decorator on the component which needs drag and drop context
@getDragDropContext class MyComponent extends Component { }
This is useful if MyComponent already has a default export