surevine / govuk-react-jsx

govuk-frontend compatible React components
https://govuk-react-jsx.netlify.app/
MIT License
3 stars 0 forks source link

Invalid Hook Call Warning #65

Closed grahamorrell closed 4 years ago

grahamorrell commented 4 years ago

Whilst attempting to use this library within a Gatsby application I was receiving the error outlined here

https://reactjs.org/warnings/invalid-hook-call-warning.html

Specifically I think the issue was "3. You might have more than one copy of React in the same app.". At the above link it mentions that libraries should list react as peer dependencies rather than dependencies.

Indeed, when I modified govuk-react-jsx\package.json to look like

"dependencies": { "govuk-frontend": "3.4.0", "react-helmet": "5", "react-router": "5", "react-router-dom": "5" }, "peerDependencies": { "react": "16"
},

The issue appears to be resolved.

andymantell commented 4 years ago

Thanks, that's a good shout. To be honest I guess the other deps ought to be peers as well. I'll do a bit of reading and check that's the right way to go and then will get this sorted asap.

andymantell commented 4 years ago

Hi @grahamorrell,

I have released govuk-react-jsx@3.0.0 with everything moved to peer dependencies (Hence the major version bump). Can you give it a try and double check it solves the issue for you.

Also have updated govuk-frontend to 3.6.0 in the (now) peer deps. This was an error previously, it should always have been 3.6.0, the dist package.json was lagging behind. (I've added some tests to make sure this doesn't happen again)

thanks,

Andy

andymantell commented 4 years ago

I'm going to consider this fixed, but please let me know if you have any more issues. Or indeed if it is now working.