junkboy0315/react-compare-image

[Problem/Bug] Invalid hook call

Closed this issue · 1 comments

I'm using

"react": "^16.12.0",
"react-dom": "^16.12.0"
"react-compare-image": "2.0.4",

Then my JSX contains

<ReactCompareImage
leftImage="https://localhost/storage/cms/MPXLjXP7UCKJ7yQxb5s3c3QXqhAdeGmvAkeMJC8R.png"
rightImage="https://localhost/storage/cms/optimised-MPXLjXP7UCKJ7yQxb5s3c3QXqhAdeGmvAkeMJC8R.png"
/>

However this is now throwing:

maelstrom.js?v=1579875532:150025 Uncaught Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
See https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.
    at resolveDispatcher (maelstrom.js?v=1579875532:150025)
    at useState (maelstrom.js?v=1579875532:150053)
    at h (maelstrom.js?v=1579875532:116681)
    at renderWithHooks (app.js?v=1579870653:43630)
    at mountIndeterminateComponent (app.js?v=1579870653:46164)
    at beginWork$1 (app.js?v=1579870653:47532)
    at HTMLUnknownElement.callCallback (app.js?v=1579870653:27706)
    at Object.invokeGuardedCallbackDev (app.js?v=1579870653:27755)
    at invokeGuardedCallback (app.js?v=1579870653:27810)
    at beginWork$$1 (app.js?v=1579870653:53150)

The error goes as soon as I remove the ReactCompareImage component from the template.

You can replicate it: https://codesandbox.io/s/react-example-920yv?fontsize=14&hidenavigation=1&theme=dark

@OwenMelbz
Your code sandbox is referencing your local picture so I cant reprocude the case.
Anyway I replaced img src to some url manually and found problems are not reproduceable.