Skip to content
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

Bump react-dnd from 11.1.3 to 14.0.2 #405

Merged

Conversation

dependabot[bot]
Copy link
Contributor

@dependabot dependabot bot commented on behalf of github Apr 5, 2021

Bumps react-dnd from 11.1.3 to 14.0.2.

Release notes

Sourced from react-dnd's releases.

v14.0.2

Patch

This PR will throw a developer exception if a user specifies a useDrag::spec.begin method.

14.0.1

Patch

Update internal hook useDragType() to align with updated typings. Check 14.0.0 release for API changes

14.0.0

This release addresses a handful of nagging liveness and ergonomic issues with the hooks API.

The liveness issues affect all hooks, and were discovered on deeper inspection of certain stress tests in the documentation. The internal useCollector() hook is used to collect props from the DnD system when things change. Prior to this update, we subscribed to updates from the DnD monitor to trigger prop collection. However, state on the react side was only accounted for on the first render. This release improves that liveness by collecting props whenever react state changes.

The ergonomics of the useDrag have been refactored. In short:

  • spec.type is required
  • spec.item can be a function or static object.
  • The function version of spec.item replaces spec.begin

Since the release of the hooks API, we packed type under spec.item. However, this led to nonintuitive situations where an item field was required to be specified even though items are created in the begin method.

Additionally, in the original React-DnD design, beginDrag() was optional and the type of the draggables had to be defined. If no explicit DragObject was created, an implicit object was created by the system..

The change we've made here decouples type from item, and collapses begin into item.

// Pre-v14
useDrag({
   // item defined here to get a type
   item: { type: BOX } },
   // ...but the actual item is created here
   begin: () => ({ id })
})
// v14
useDrag({
type: BOX,
item: () => ({id})
})

e.g. useDrag({ item: { type: BOX }}) => useDrag({ type: 'BOX' })

We've also added the ability to cancel drag operations in the hooks API by returning null from begin.

// new API
useDrag({
  type: BOX,
  item: () => shouldNotDrag ? null : {id},
})
</tr></table> 

... (truncated)

Commits

Dependabot compatibility score

You can trigger a rebase of this PR by commenting @dependabot rebase.


Dependabot commands and options

You can trigger Dependabot actions by commenting on this PR:

  • @dependabot rebase will rebase this PR
  • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
  • @dependabot merge will merge this PR after your CI passes on it
  • @dependabot squash and merge will squash and merge this PR after your CI passes on it
  • @dependabot cancel merge will cancel a previously requested merge and block automerging
  • @dependabot reopen will reopen this PR if it is closed
  • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
  • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

@dependabot dependabot bot added the dependencies Issues or updates to dependency files label Apr 5, 2021
@dependabot dependabot bot added this to the v1.0.0 milestone Apr 5, 2021
@dependabot dependabot bot force-pushed the dependabot/npm_and_yarn/development/react-dnd-14.0.2 branch from 481f87f to b1ec3ff Compare May 3, 2021 05:07
@nelsonni nelsonni force-pushed the dependabot/npm_and_yarn/development/react-dnd-14.0.2 branch from b1ec3ff to ab05ca6 Compare June 30, 2021 22:46
@nelsonni
Copy link
Member

ERROR in src/components/CanvasComponent.tsx:46:15
TS2571: Object is of type 'unknown'.
    44 |     accept: ['CARD', 'STACK'],
    45 |     canDrop: (_item, monitor) => {
  > 46 |       return !monitor.getItem().captured;
       |               ^^^^^^^^^^^^^^^^^
    47 |     },
    48 |     drop: (item, monitor) => {
    49 |       switch (item.type) {

ERROR in src/components/CanvasComponent.tsx:49:15
TS2571: Object is of type 'unknown'.
    47 |     },
    48 |     drop: (item, monitor) => {
  > 49 |       switch (item.type) {
       |               ^^^^
    50 |         case 'CARD': {
    51 |           const card = cards[monitor.getItem().id];
    52 |           const delta = monitor.getDifferenceFromInitialOffset();

ERROR in src/components/CanvasComponent.tsx:51:30
TS2571: Object is of type 'unknown'.
    49 |       switch (item.type) {
    50 |         case 'CARD': {
  > 51 |           const card = cards[monitor.getItem().id];
       |                              ^^^^^^^^^^^^^^^^^
    52 |           const delta = monitor.getDifferenceFromInitialOffset();
    53 |           if (!delta) return; // no dragging is occurring, perhaps a card was picked up and dropped without dragging
    54 |           if (card.captured) {

ERROR in src/components/CanvasComponent.tsx:62:32
TS2571: Object is of type 'unknown'.
    60 |         }
    61 |         case 'STACK': {
  > 62 |           const stack = stacks[monitor.getItem().id];
       |                                ^^^^^^^^^^^^^^^^^
    63 |           const delta = monitor.getDifferenceFromInitialOffset();
    64 |           if (!delta) return; // no dragging is occurring, perhaps a stack was picked up and dropped without dragging
    65 |           dispatch(updateStack({ ...stack, left: Math.round(stack.left + delta.x), top: Math.round(stack.top + delta.y) }));

ERROR in src/components/CardComponent.tsx:85:12
TS2339: Property 'isDragging' does not exist on type 'unknown'.
    83 | 
    84 |   // Enable CardComponent as a drop source (i.e. allowing this card to be draggable)
  > 85 |   const [{ isDragging }, drag] = useDrag({
       |            ^^^^^^^^^^
    86 |     item: { type: 'CARD', id: props.id },
    87 |     collect: monitor => ({
    88 |       isDragging: !!monitor.isDragging(),

ERROR in src/components/CardComponent.tsx:85:42
TS2345: Argument of type '{ item: { type: string; id: string; }; collect: (monitor: DragSourceMonitor<{ type: string; id: string; }, unknown>) => { isDragging: boolean; }; }' is not assignable to parameter of type 'FactoryOrInstance<DragSourceHookSpec<{ type: string; id: string; }, unknown, unknown>>'.
  Property 'type' is missing in type '{ item: { type: string; id: string; }; collect: (monitor: DragSourceMonitor<{ type: string; id: string; }, unknown>) => { isDragging: boolean; }; }' but required in type 'DragSourceHookSpec<{ type: string; id: string; }, unknown, unknown>'.
    83 | 
    84 |   // Enable CardComponent as a drop source (i.e. allowing this card to be draggable)
  > 85 |   const [{ isDragging }, drag] = useDrag({
       |                                          ^
  > 86 |     item: { type: 'CARD', id: props.id },
       | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  > 87 |     collect: monitor => ({
       | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  > 88 |       isDragging: !!monitor.isDragging(),
       | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  > 89 |     }),
       | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  > 90 |   });
       | ^^^^
    91 | 
    92 |   // Enable CardComponent as a drop target (i.e. allow other elements to be dropped on this card)
    93 |   const [{ isOver }, drop] = useDrop({

ERROR in src/components/CardComponent.tsx:97:26
TS2571: Object is of type 'unknown'.
     95 |     canDrop: (item, monitor) => {
     96 |       const dropTarget = cards[props.id];
  >  97 |       const dropSource = item.type === 'CARD' ? cards[monitor.getItem().id] : stacks[monitor.getItem().id];
        |                          ^^^^
     98 |       return dropTarget.id !== dropSource.id; // restrict dropped items from accepting a self-referencing drop (i.e. dropping a card on itself)
     99 |     },
    100 |     drop: (item, monitor) => {

ERROR in src/components/CardComponent.tsx:97:55
TS2571: Object is of type 'unknown'.
     95 |     canDrop: (item, monitor) => {
     96 |       const dropTarget = cards[props.id];
  >  97 |       const dropSource = item.type === 'CARD' ? cards[monitor.getItem().id] : stacks[monitor.getItem().id];
        |                                                       ^^^^^^^^^^^^^^^^^
     98 |       return dropTarget.id !== dropSource.id; // restrict dropped items from accepting a self-referencing drop (i.e. dropping a card on itself)
     99 |     },
    100 |     drop: (item, monitor) => {

ERROR in src/components/CardComponent.tsx:97:86
TS2571: Object is of type 'unknown'.
     95 |     canDrop: (item, monitor) => {
     96 |       const dropTarget = cards[props.id];
  >  97 |       const dropSource = item.type === 'CARD' ? cards[monitor.getItem().id] : stacks[monitor.getItem().id];
        |                                                                                      ^^^^^^^^^^^^^^^^^
     98 |       return dropTarget.id !== dropSource.id; // restrict dropped items from accepting a self-referencing drop (i.e. dropping a card on itself)
     99 |     },
    100 |     drop: (item, monitor) => {

ERROR in src/components/CardComponent.tsx:104:15
TS2571: Object is of type 'unknown'.
    102 |       const delta = monitor.getDifferenceFromInitialOffset();
    103 |       if (!delta) return; // no dragging is occurring, perhaps a draggable element was picked up and dropped without dragging
  > 104 |       switch (item.type) {
        |               ^^^^
    105 |         case 'CARD': {
    106 |           const dropSource = cards[monitor.getItem().id];
    107 |           if (dropSource.captured) {

ERROR in src/components/CardComponent.tsx:106:36
TS2571: Object is of type 'unknown'.
    104 |       switch (item.type) {
    105 |         case 'CARD': {
  > 106 |           const dropSource = cards[monitor.getItem().id];
        |                                    ^^^^^^^^^^^^^^^^^
    107 |           if (dropSource.captured) {
    108 |             dispatch(popCard(stacks[dropSource.captured], dropSource, delta));
    109 |           }

ERROR in src/components/CardComponent.tsx:121:39
TS2571: Object is of type 'unknown'.
    119 |         case 'STACK': {
    120 |           if (!props.captured) {
  > 121 |             const dropSource = stacks[monitor.getItem().id];
        |                                       ^^^^^^^^^^^^^^^^^
    122 |             const actions = pushCards(dropSource, [dropTarget]);
    123 |             actions.map(action => dispatch(action));
    124 |           }

ERROR in src/components/StackComponent.tsx:17:12
TS2339: Property 'isDragging' does not exist on type 'unknown'.
    15 | 
    16 |   // Enable StackComponent as a drop source (i.e. allowing this stack to be draggable)
  > 17 |   const [{ isDragging }, drag] = useDrag({
       |            ^^^^^^^^^^
    18 |     item: { type: 'STACK', id: props.id },
    19 |     collect: monitor => ({
    20 |       item: monitor.getItem(),

ERROR in src/components/StackComponent.tsx:17:42
TS2345: Argument of type '{ item: { type: string; id: string; }; collect: (monitor: DragSourceMonitor<{ type: string; id: string; }, unknown>) => { item: { type: string; id: string; }; isDragging: boolean; }; }' is not assignable to parameter of type 'FactoryOrInstance<DragSourceHookSpec<{ type: string; id: string; }, unknown, unknown>>'.
  Property 'type' is missing in type '{ item: { type: string; id: string; }; collect: (monitor: DragSourceMonitor<{ type: string; id: string; }, unknown>) => { item: { type: string; id: string; }; isDragging: boolean; }; }' but required in type 'DragSourceHookSpec<{ type: string; id: string; }, unknown, unknown>'.
    15 | 
    16 |   // Enable StackComponent as a drop source (i.e. allowing this stack to be draggable)
  > 17 |   const [{ isDragging }, drag] = useDrag({
       |                                          ^
  > 18 |     item: { type: 'STACK', id: props.id },
       | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  > 19 |     collect: monitor => ({
       | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  > 20 |       item: monitor.getItem(),
       | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  > 21 |       isDragging: !!monitor.isDragging()
       | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  > 22 |     })
       | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  > 23 |   });
       | ^^^^
    24 | 
    25 |   // Enable StackComponent as a drop target (i.e. allow other elements to be dropped on this stack)
    26 |   const [, drop] = useDrop({

ERROR in src/components/StackComponent.tsx:30:26
TS2571: Object is of type 'unknown'.
    28 |     canDrop: (item, monitor) => {
    29 |       const dropTarget = stacks[props.id];
  > 30 |       const dropSource = item.type === 'CARD' ? cards[monitor.getItem().id] : stacks[monitor.getItem().id];
       |                          ^^^^
    31 |       return dropTarget && dropTarget.id !== dropSource.id; // restrict dropped items from accepting a self-referencing drop (i.e. dropping a stack on itself)
    32 |     },
    33 |     drop: (item, monitor) => {

ERROR in src/components/StackComponent.tsx:30:55
TS2571: Object is of type 'unknown'.
    28 |     canDrop: (item, monitor) => {
    29 |       const dropTarget = stacks[props.id];
  > 30 |       const dropSource = item.type === 'CARD' ? cards[monitor.getItem().id] : stacks[monitor.getItem().id];
       |                                                       ^^^^^^^^^^^^^^^^^
    31 |       return dropTarget && dropTarget.id !== dropSource.id; // restrict dropped items from accepting a self-referencing drop (i.e. dropping a stack on itself)
    32 |     },
    33 |     drop: (item, monitor) => {

ERROR in src/components/StackComponent.tsx:30:86
TS2571: Object is of type 'unknown'.
    28 |     canDrop: (item, monitor) => {
    29 |       const dropTarget = stacks[props.id];
  > 30 |       const dropSource = item.type === 'CARD' ? cards[monitor.getItem().id] : stacks[monitor.getItem().id];
       |                                                                                      ^^^^^^^^^^^^^^^^^
    31 |       return dropTarget && dropTarget.id !== dropSource.id; // restrict dropped items from accepting a self-referencing drop (i.e. dropping a stack on itself)
    32 |     },
    33 |     drop: (item, monitor) => {

ERROR in src/components/StackComponent.tsx:36:15
TS2571: Object is of type 'unknown'.
    34 |       const delta = monitor.getDifferenceFromInitialOffset();
    35 |       if (!delta) return; // no dragging is occurring, perhaps a draggable element was picked up and dropped without dragging
  > 36 |       switch (item.type) {
       |               ^^^^
    37 |         case 'CARD': {
    38 |           const dropTarget = stacks[props.id];
    39 |           const dropSource = cards[monitor.getItem().id];

ERROR in src/components/StackComponent.tsx:39:36
TS2571: Object is of type 'unknown'.
    37 |         case 'CARD': {
    38 |           const dropTarget = stacks[props.id];
  > 39 |           const dropSource = cards[monitor.getItem().id];
       |                                    ^^^^^^^^^^^^^^^^^
    40 |           if (dropSource.captured) {
    41 |             dispatch(popCard(dropTarget, dropSource, delta));
    42 |           }

ERROR in src/components/StackComponent.tsx:47:37
TS2571: Object is of type 'unknown'.
    45 |         case 'STACK': {
    46 |           const dropTarget = stacks[props.id];
  > 47 |           const dropSource = stacks[monitor.getItem().id];
       |                                     ^^^^^^^^^^^^^^^^^
    48 |           const actions: Action[] = pushCards(dropTarget, dropSource.cards.map(id => cards[id]));
    49 |           actions.push({ type: ActionKeys.REMOVE_STACK, id: dropSource.id });
    50 |           actions.map(action => dispatch(action));

Copy link
Member

@nelsonni nelsonni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Must resolve runtime errors thrown by Electron-Forge and Webpack (see issue comment for error messages).

@nelsonni
Copy link
Member

nelsonni commented Jul 1, 2021

Per previous discussion in #358 (comment), react-dnd@13.0.0 introduced a dependency on React v17.0.0. Therefore, this PR is dependent on PR #453 getting integrated first.

@nelsonni nelsonni merged commit 113789c into development Jul 6, 2021
@nelsonni nelsonni deleted the dependabot/npm_and_yarn/development/react-dnd-14.0.2 branch July 6, 2021 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Issues or updates to dependency files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant