Skip to content

Commit 0bc9d08

Browse files
authored
Task/remove proptypes (#1077)
* Remove proptypes dependency * Use a git hash for now for react-frame-component until they release 4.0.1 or greater that includes the SSR fix
1 parent f2b0a3a commit 0bc9d08

File tree

45 files changed

+15
-329
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+15
-329
lines changed

packages/dnd-core/src/HandlerRegistryImpl.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { Store } from 'redux'
22
import invariant from 'invariant'
3-
import isArray from 'lodash/isArray'
43
import {
54
addSource,
65
addTarget,

packages/documentation/examples/00 Chessboard/Tutorial App/Board.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React from 'react'
2-
import PropTypes from 'prop-types'
32
import { DragDropContext } from 'react-dnd'
43
import HTML5Backend, { HTML5BackendContext } from 'react-dnd-html5-backend'
54
import BoardSquare from './BoardSquare'
@@ -12,10 +11,6 @@ export interface BoardProps {
1211

1312
@DragDropContext<BoardProps, {}, Board>(HTML5Backend)
1413
export default class Board extends React.Component<BoardProps> {
15-
public static propTypes = {
16-
knightPosition: PropTypes.arrayOf(PropTypes.number.isRequired).isRequired,
17-
}
18-
1914
public render() {
2015
const squares = []
2116
for (let i = 0; i < 64; i += 1) {

packages/documentation/examples/00 Chessboard/Tutorial App/BoardSquare.tsx

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React from 'react'
2-
import PropTypes from 'prop-types'
32
import {
43
DropTarget,
54
DropTargetMonitor,
@@ -45,15 +44,6 @@ const collect: DropTargetCollector<CollectedProps> = (
4544

4645
@DropTarget(ItemTypes.KNIGHT, squareTarget, collect)
4746
export default class BoardSquare extends React.Component<BoardSquareProps> {
48-
public static propTypes = {
49-
x: PropTypes.number.isRequired,
50-
y: PropTypes.number.isRequired,
51-
isOver: PropTypes.bool.isRequired,
52-
canDrop: PropTypes.bool.isRequired,
53-
connectDropTarget: PropTypes.func.isRequired,
54-
children: PropTypes.node,
55-
}
56-
5747
public render() {
5848
const { x, y, connectDropTarget, isOver, canDrop, children } = this.props
5949
const black = (x + y) % 2 === 1

packages/documentation/examples/00 Chessboard/Tutorial App/Knight.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React from 'react'
2-
import PropTypes from 'prop-types'
32
import {
43
DragSource,
54
ConnectDragSource,
@@ -33,12 +32,6 @@ export interface KnightProps {
3332

3433
@DragSource(ItemTypes.KNIGHT, knightSource, collect)
3534
export default class Knight extends React.Component<KnightProps> {
36-
public static propTypes = {
37-
connectDragSource: PropTypes.func.isRequired,
38-
connectDragPreview: PropTypes.func.isRequired,
39-
isDragging: PropTypes.bool.isRequired,
40-
}
41-
4235
public componentDidMount() {
4336
const img = new Image()
4437
img.src =

packages/documentation/examples/00 Chessboard/Tutorial App/Square.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
import React from 'react'
2-
import PropTypes from 'prop-types'
32

43
export interface SquareProps {
54
black: boolean
65
children: JSX.Element
76
}
87

98
export default class Square extends React.Component<SquareProps> {
10-
public static propTypes = {
11-
black: PropTypes.bool,
12-
children: PropTypes.node,
13-
}
14-
159
public render() {
1610
const { black } = this.props
1711
const backgroundColor = black ? 'black' : 'white'

packages/documentation/examples/01 Dustbin/Copy or Move/Box.tsx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import React from 'react'
2-
import PropTypes from 'prop-types'
32
import {
43
DragSource,
54
ConnectDragSource,
65
DragSourceConnector,
76
DragSourceMonitor,
87
} from 'react-dnd'
98
import ItemTypes from '../Single Target/ItemTypes'
10-
import { DragDropManager } from 'dnd-core'
119

1210
const style: React.CSSProperties = {
1311
border: '1px dashed gray',
@@ -64,12 +62,6 @@ export interface BoxProps {
6462
}),
6563
)
6664
export default class Box extends React.Component<BoxProps> {
67-
public static propTypes = {
68-
connectDragSource: PropTypes.func.isRequired,
69-
isDragging: PropTypes.bool.isRequired,
70-
name: PropTypes.string.isRequired,
71-
}
72-
7365
public render() {
7466
const { isDragging, connectDragSource } = this.props
7567
const { name } = this.props

packages/documentation/examples/01 Dustbin/Copy or Move/Dustbin.tsx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React from 'react'
2-
import PropTypes from 'prop-types'
32
import { DropTarget, ConnectDropTarget } from 'react-dnd'
43
import ItemTypes from '../Single Target/ItemTypes'
54

@@ -38,13 +37,6 @@ export interface DustbinProps {
3837
canDrop: monitor.canDrop(),
3938
}))
4039
export default class Dustbin extends React.Component<DustbinProps> {
41-
public static propTypes = {
42-
connectDropTarget: PropTypes.func.isRequired,
43-
isOver: PropTypes.bool.isRequired,
44-
canDrop: PropTypes.bool.isRequired,
45-
allowedDropEffect: PropTypes.string.isRequired,
46-
}
47-
4840
public render() {
4941
const { canDrop, isOver, allowedDropEffect, connectDropTarget } = this.props
5042
const isActive = canDrop && isOver

packages/documentation/examples/01 Dustbin/Multiple Targets/Box.tsx

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React from 'react'
2-
import PropTypes from 'prop-types'
32
import {
43
DragSource,
54
ConnectDragSource,
@@ -41,14 +40,6 @@ export interface BoxProps {
4140
}),
4241
)
4342
export default class Box extends React.Component<BoxProps> {
44-
public static propTypes = {
45-
connectDragSource: PropTypes.func.isRequired,
46-
isDragging: PropTypes.bool.isRequired,
47-
name: PropTypes.string.isRequired,
48-
type: PropTypes.string.isRequired,
49-
isDropped: PropTypes.bool.isRequired,
50-
}
51-
5243
public render() {
5344
const { name, isDropped, isDragging, connectDragSource } = this.props
5445
const opacity = isDragging ? 0.4 : 1

packages/documentation/examples/01 Dustbin/Multiple Targets/Dustbin.tsx

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React from 'react'
2-
import PropTypes from 'prop-types'
32
import { DropTarget, ConnectDropTarget, DropTargetMonitor } from 'react-dnd'
43

54
const style: React.CSSProperties = {
@@ -40,15 +39,6 @@ export interface DustbinProps {
4039
}),
4140
)
4241
export default class Dustbin extends React.Component<DustbinProps> {
43-
public static propTypes = {
44-
connectDropTarget: PropTypes.func.isRequired,
45-
isOver: PropTypes.bool.isRequired,
46-
canDrop: PropTypes.bool.isRequired,
47-
accepts: PropTypes.arrayOf(PropTypes.string).isRequired,
48-
lastDroppedItem: PropTypes.object,
49-
onDrop: PropTypes.func.isRequired,
50-
}
51-
5242
public render() {
5343
const {
5444
accepts,

packages/documentation/examples/01 Dustbin/Single Target in iframe/Container.tsx

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,23 @@
11
import React from 'react'
2-
import PropTypes from 'prop-types'
32
import { DragDropContextProvider } from 'react-dnd'
43
import HTML5Backend from 'react-dnd-html5-backend'
54
import Dustbin from '../Single Target/Dustbin'
65
import Box from '../Single Target/Box'
7-
8-
// TODO: Update this example when react-frame-component uses the official context API
9-
const Frame = require('react-frame-component').default
6+
const {
7+
default: Frame,
8+
FrameContextConsumer,
9+
} = require('react-frame-component')
1010

1111
class FrameBindingContext extends React.Component {
12-
public static contextTypes = {
13-
window: PropTypes.object,
14-
}
15-
public static propTypes = {
16-
children: PropTypes.node,
17-
}
18-
19-
get dragDropContext() {
20-
return {
21-
window: this.context.window,
22-
}
23-
}
24-
2512
public render() {
2613
return (
27-
<DragDropContextProvider
28-
backend={HTML5Backend}
29-
context={this.dragDropContext}
30-
>
31-
{this.props.children}
32-
</DragDropContextProvider>
14+
<FrameContextConsumer>
15+
{({ window }: any) => (
16+
<DragDropContextProvider backend={HTML5Backend} context={window}>
17+
{this.props.children}
18+
</DragDropContextProvider>
19+
)}
20+
</FrameContextConsumer>
3321
)
3422
}
3523
}

0 commit comments

Comments
 (0)