0

I have published my first package. It works except one component. That component has a dependency on another package (not mine) when I test it with npm link without that dependency it works. But with a dependency I have an 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' I don't use hooks in my project.

My code:

    render() {

        return (
          <div>
            <MediaQuery>
                  ...
            </MediaQuery>
         </div>
)
}

The problem is in MediaQuery. Without it, my package works. But I need this dependency. How to handle it?

Noa
  • 424
  • 1
  • 3
  • 16
  • 1
    Can you provide your repository? And what is the name of that dependency that is not yours? – Neskews Jun 15 '19 at 18:36
  • yes, sure repository is https://github.com/NataliaGon/package-grid-react . Not my dependency is from "react-responsive". I see the mistake just when I use npm link, when I use package -no mistake but I don't see component - just empty
    – Noa Jun 15 '19 at 21:31

0 Answers0