MCPcopy Create free account
hub / github.com/react-dnd/react-dnd / render

Method render

examples/03 Nesting/Drag Sources/SourceBox.js:36–70  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

34 };
35
36 render() {
37 const { color, children, isDragging, connectDragSource, forbidDrag, onToggleForbidDrag } = this.props;
38 const opacity = isDragging ? 0.4 : 1;
39
40 let backgroundColor;
41 switch (color) {
42 case Colors.YELLOW:
43 backgroundColor = 'lightgoldenrodyellow';
44 break;
45 case Colors.BLUE:
46 backgroundColor = 'lightblue';
47 break;
48 default:
49 break;
50 }
51
52 return connectDragSource(
53 <div
54 style={{
55 ...style,
56 backgroundColor,
57 opacity,
58 cursor: forbidDrag ? 'default' : 'move',
59 }}
60 >
61 <input
62 type="checkbox"
63 checked={forbidDrag}
64 onChange={onToggleForbidDrag}
65 />
66 <small>Forbid drag</small>
67 {children}
68 </div>,
69 );
70 }
71}
72
73export default class StatefulSourceBox extends Component {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected