WordPress 6.1.1 comes with React 17 but @wordpress/element requires React 18
-
Hi! I have a clean install of WordPress 6.1.1 where I want to use Gutenberg blocks with React and I’ve noticed it comes with React 17.
https://prnt.sc/bVKB5VlSle5O
In the network tab I can see it loads React 17.0.1
https://prnt.sc/fLzoppgb-8FI
I can’t use React hooks likeuseState
from@wordpress/element
because it throws this error https://reactjs.org/docs/error-decoder.html/?invariant=321
After some digging I found out it requires React 18.2.0
https://prnt.sc/H3r1ekNT3bV9I’ve also tried debugging by using the methods from Duplicate React and indeed it prints false: https://reactjs.org/warnings/invalid-hook-call-warning.html
npm ls react
shows this:
https://prnt.sc/ussfpbTQeCf6So…I really don’t know what’s going on, any help would be appreciated, thank you!
- The topic ‘WordPress 6.1.1 comes with React 17 but @wordpress/element requires React 18’ is closed to new replies.