Skip to content

Update to React-dnd 8. Add forward ref to scrolling component #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
{
"name": "frontend-collective-react-dnd-scrollzone",
"version": "1.0.2",
"name": "@zenhubhq/react-dnd-scrollzone",
"version": "5.0.1",
"description": "A cross browser solution to scrolling during drag and drop.",
"main": "lib/index.js",
"scripts": {
"build": "rm -rf lib && babel src --out-dir lib",
"lint": "eslint src",
"pretest": "npm run lint",
"test": "mocha test",
"prepublish": "in-publish && npm run test && npm run build || not-in-publish",
"prepublish": "in-publish && npm run build || not-in-publish",
"publish:major": "npm version major && npm publish",
"publish:minor": "npm version minor && npm publish",
"publish:patch": "npm version patch && npm publish",
"postpublish": "git push origin master --tags"
},
"repository": {
"type": "git",
"url": "https://github.com/frontend-collective/react-dnd-scrollzone"
"url": "https://github.com/ZenHubHQ/react-dnd-scrollzone"
},
"bugs": {
"url": "http://github.com/frontend-collective/react-dnd-scrollzone/issues"
"url": "https://github.com/ZenHubHQ/react-dnd-scrollzone/issues"
},
"keywords": [
"react",
Expand All @@ -38,7 +38,7 @@
},
"license": "MIT",
"dependencies": {
"hoist-non-react-statics": "^3.1.0",
"hoist-non-react-statics": "^3.3.0",
"lodash.throttle": "^4.0.1",
"prop-types": "^15.5.9",
"raf": "^3.2.0",
Expand All @@ -60,15 +60,15 @@
"eslint-plugin-react": "^7.11.1",
"in-publish": "^2.0.0",
"mocha": "^5.2.0",
"react": "^16.3.0",
"react-dnd": "^7.3.0",
"react-dom": "^16.3.0",
"react": "^16.8.6",
"react-dnd": "^8.0.3",
"react-dom": "^16.8.6",
"sinon": "^7.1.1",
"sinon-chai": "^3.2.0"
},
"peerDependencies": {
"react": "^16.3.0",
"react-dnd": "^7.3.0",
"react-dom": "^16.3.0"
"react": "^16.8.6",
"react-dnd": "^8.0.3",
"react-dom": "^16.8.6"
}
}
16 changes: 8 additions & 8 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React, { Component } from 'react';
import React, { Component, forwardRef } from 'react';
import PropTypes from 'prop-types';
import { findDOMNode } from 'react-dom';
import throttle from 'lodash.throttle';
import raf from 'raf';
import getDisplayName from 'react-display-name';
import { DragDropContextConsumer } from 'react-dnd';
import { DndContext } from 'react-dnd';
import hoist from 'hoist-non-react-statics';
import { noop, intBetween, getCoords } from './util';

Expand Down Expand Up @@ -240,7 +240,7 @@ export function createScrollingComponent(WrappedComponent) {
verticalStrength,
horizontalStrength,
onScrollChange,

dragDropManager,
...props
} = this.props;

Expand All @@ -258,13 +258,13 @@ export function createScrollingComponent(WrappedComponent) {

export default function createScrollingComponentWithConsumer(WrappedComponent) {
const ScrollingComponent = createScrollingComponent(WrappedComponent);
return props => (
<DragDropContextConsumer>
return forwardRef((props, ref) => (
<DndContext.Consumer>
{({ dragDropManager }) => (
dragDropManager === undefined
? null
: <ScrollingComponent {...props} dragDropManager={dragDropManager} />
: <ScrollingComponent {...props} ref={ref} dragDropManager={dragDropManager} />
)}
</DragDropContextConsumer>
);
</DndContext.Consumer>
));
}
Loading