Skip to content

Instantly share code, notes, and snippets.

@chestozo
Last active May 28, 2021 17:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chestozo/4f37d4584156250df9c62dc7fcbc0467 to your computer and use it in GitHub Desktop.
Save chestozo/4f37d4584156250df9c62dc7fcbc0467 to your computer and use it in GitHub Desktop.
How to fix react-dnd "Invariant Violation: Cannot call hover while not dragging." issue

In our case were getting this issue before we moved the data-testid attribute onto Dropzone input props like this:

<Dropzone
  onDrop={onDrop}
  accept={accept}
  style={{}}
  onClick={onClick}
  inputProps={{
    'data-testid': 'drop-file-input',
  }}
>
  ...
</>

and this is how we trigger drop file:

const uploadLogoInput = await screen.findByTestId('drop-file-input')
fireEvent.drop(uploadLogoInput, { target: { files: [validPngFile] } })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment