Skip to content

Commit

Permalink
Update Libraries, Correct some Invariant Issues (#1313)
Browse files Browse the repository at this point in the history
* chore: update react and typescript

* fix: correct ts issues with ref-forwarding components

* fix: update the getDecoratedComponent function to avoid the invariant
  • Loading branch information
darthtrevino committed Apr 2, 2019
1 parent 69dbcce commit 676d9f8
Show file tree
Hide file tree
Showing 13 changed files with 730 additions and 686 deletions.
6 changes: 3 additions & 3 deletions package.json
Expand Up @@ -68,13 +68,13 @@
"npm": "^6.9.0",
"npm-run-all": "^4.1.5",
"prettier": "^1.16.4",
"react": "^16.8.5",
"react-dom": "^16.8.5",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"ts-jest": "^24.0.0",
"tslint": "^5.13.1",
"tslint-config-prettier": "^1.18.0",
"tslint-react": "^4.0.0",
"typescript": "^3.3.3333"
"typescript": "^3.4.1"
},
"jest": {
"clearMocks": true,
Expand Down
2 changes: 1 addition & 1 deletion packages/dnd-core/package.json
Expand Up @@ -25,6 +25,6 @@
"devDependencies": {
"npm-run-all": "^4.1.5",
"rimraf": "^2.6.3",
"typescript": "^3.3.3333"
"typescript": "^3.4.1"
}
}
8 changes: 4 additions & 4 deletions packages/documentation/package.json
Expand Up @@ -6,8 +6,8 @@
"license": "MIT",
"dependencies": {
"@types/query-string": "^6.2.0",
"@types/react": "^16.8.7",
"@types/react-dom": "^16.8.2",
"@types/react": "^16.8.10",
"@types/react-dom": "^16.8.3",
"@types/react-helmet": "^5.0.8",
"@types/react-tabs": "^2.3.1",
"gatsby": "^2.1.23",
Expand All @@ -29,13 +29,13 @@
"gatsby-transformer-sharp": "^2.1.15",
"prismjs": "^1.15.0",
"query-string": "^6.3.0",
"react": "^16.8.5",
"react": "^16.8.6",
"react-dnd": "^7.4.3",
"react-dnd-examples": "^7.4.3",
"react-dnd-examples-hooks": "^7.4.3",
"react-dnd-html5-backend": "^7.4.0",
"react-dnd-test-backend": "^7.4.0",
"react-dom": "^16.8.5",
"react-dom": "^16.8.6",
"react-helmet": "^5.2.0",
"react-tabs": "^3.0.0",
"react-typography": "^0.16.18",
Expand Down
10 changes: 5 additions & 5 deletions packages/examples-hooks/package.json
Expand Up @@ -31,14 +31,14 @@
"react-frame-component": "^4.1.0"
},
"devDependencies": {
"@types/react": "^16.8.7",
"@types/react-dom": "^16.8.2",
"@types/react": "^16.8.10",
"@types/react-dom": "^16.8.3",
"npm-run-all": "^4.1.5",
"react-dnd-test-utils": "7.4.0",
"react": "^16.8.5",
"react-dom": "^16.8.5",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"rimraf": "^2.6.3",
"typescript": "^3.3.3333"
"typescript": "^3.4.1"
},
"peerDependencies": {
"react": ">= 16.8.5",
Expand Down
10 changes: 5 additions & 5 deletions packages/examples/package.json
Expand Up @@ -31,14 +31,14 @@
"react-frame-component": "^4.1.0"
},
"devDependencies": {
"@types/react": "^16.8.7",
"@types/react-dom": "^16.8.2",
"@types/react": "^16.8.10",
"@types/react-dom": "^16.8.3",
"npm-run-all": "^4.1.5",
"react": "^16.8.5",
"react": "^16.8.6",
"react-dnd-test-utils": "7.4.0",
"react-dom": "^16.8.5",
"react-dom": "^16.8.6",
"rimraf": "^2.6.3",
"typescript": "^3.3.3333"
"typescript": "^3.4.1"
},
"peerDependencies": {
"react": ">= 16.8.5",
Expand Down
7 changes: 2 additions & 5 deletions packages/examples/src/03-nesting/drop-targets/Dustbin.tsx
Expand Up @@ -30,16 +30,13 @@ export interface DustbinState {
hasDroppedOnChild: boolean
}

const Dustbin: React.RefForwardingComponent<
any,
DustbinProps
> = React.forwardRef(
const Dustbin = React.forwardRef<HTMLDivElement, DustbinProps>(
({ greedy, isOver, isOverCurrent, connectDropTarget, children }, ref) => {
const [hasDropped, setHasDropped] = useState(false)
const [hasDroppedOnChild, setHasDroppedOnChild] = useState(false)

useImperativeHandle(
ref,
ref as any,
() => ({
onDrop: (onChild: boolean) => {
setHasDroppedOnChild(onChild)
Expand Down
5 changes: 1 addition & 4 deletions packages/examples/src/04-sortable/simple/Card.tsx
Expand Up @@ -35,10 +35,7 @@ interface CardInstance {
getNode(): HTMLDivElement | null
}

const Card: React.RefForwardingComponent<
HTMLDivElement,
CardProps
> = React.forwardRef(
const Card = React.forwardRef<HTMLDivElement, CardProps>(
({ text, isDragging, connectDragSource, connectDropTarget }, ref) => {
const elementRef = useRef(null)
connectDragSource(elementRef)
Expand Down
8 changes: 4 additions & 4 deletions packages/react-dnd-html5-backend/package.json
Expand Up @@ -24,14 +24,14 @@
"dnd-core": "^7.4.0"
},
"devDependencies": {
"@types/react": "^16.8.7",
"@types/react": "^16.8.10",
"npm-run-all": "^4.1.5",
"react-dnd-test-backend": "^7.4.0",
"react": "^16.8.5",
"react-dom": "^16.8.5",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"rimraf": "^2.6.3",
"ts-loader": "^5.3.3",
"typescript": "^3.3.3333",
"typescript": "^3.4.1",
"webpack": "^4.29.6",
"webpack-cli": "^3.2.3"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/react-dnd-test-backend/package.json
Expand Up @@ -23,6 +23,6 @@
"devDependencies": {
"npm-run-all": "^4.1.5",
"rimraf": "^2.6.3",
"typescript": "^3.3.3333"
"typescript": "^3.4.1"
}
}
6 changes: 3 additions & 3 deletions packages/react-dnd-test-utils/package.json
Expand Up @@ -12,11 +12,11 @@
},
"devDependencies": {
"npm-run-all": "^4.1.5",
"react": "^16.8.5",
"react-dom": "^16.8.5",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-dnd-test-backend": "^7.4.0",
"rimraf": "^2.6.3",
"typescript": "^3.3.3333"
"typescript": "^3.4.1"
},
"peerDependencies": {
"react": ">= 16.8.5",
Expand Down
10 changes: 5 additions & 5 deletions packages/react-dnd/package.json
Expand Up @@ -30,15 +30,15 @@
"@babel/cli": "^7.2.3",
"@babel/core": "^7.3.4",
"@types/hoist-non-react-statics": "^3.3.0",
"@types/react": "^16.8.7",
"@types/react-dom": "^16.8.2",
"@types/react": "^16.8.10",
"@types/react-dom": "^16.8.3",
"babel-loader": "^8.0.5",
"npm-run-all": "^4.1.5",
"react": "^16.8.5",
"react-dom": "^16.8.5",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"rimraf": "^2.6.3",
"ts-loader": "^5.3.3",
"typescript": "^3.3.3333",
"typescript": "^3.4.1",
"webpack": "^4.29.6",
"webpack-cli": "^3.2.3"
},
Expand Down
5 changes: 3 additions & 2 deletions packages/react-dnd/src/utils/getDecoratedComponent.ts
Expand Up @@ -2,8 +2,9 @@ export function getDecoratedComponent(instanceRef: React.RefObject<any>) {
const currentRef = instanceRef.current
if (currentRef == null) {
return null
} else if (typeof currentRef.getDecoratedComponentInstance === 'function') {
return currentRef.getDecoratedComponentInstance()
} else if (currentRef.decoratedRef) {
// go through the private field in decorateHandler to avoid the invariant hit
return currentRef.decoratedRef.current
} else {
return currentRef
}
Expand Down

0 comments on commit 676d9f8

Please sign in to comment.