question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Warning: Failed context type: The context `dragDropManager` is marked as required in `DropTarget(ScheduleCell)`, but its value is `undefined`.

See original GitHub issue

with 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:closed
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
th3fallencommented, Mar 16, 2018

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. @willluck

0reactions
nagendradarlacommented, Jul 23, 2020

You 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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found