-
Notifications
You must be signed in to change notification settings - Fork 240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to write a functional component using hooks (Error: Invalid hook call) #265
Comments
Hey there! 👋 @adiyathemighty and I have spent some time investigating this today and can say that this happens because of a React version mismatch (project running It can be reproduced with a barebone Next app though: npx create-next-app react-live-test
npm install react-live In import { LiveProvider, LiveEditor, LiveError, LivePreview } from "react-live";
export default function Home() {
return (
<LiveProvider code="<strong>Hello world</strong>">
<LiveEditor />
<LiveError />
<LivePreview />
</LiveProvider>
);
} Running
There doesn’t seem to be an easy workaround beyond downgrading react-live to 2.2.3, the latest version compatible with React 17 + SSR. Any further version will cause an error until react-live relies on React 17 as well instead of 16.8.0. |
Same issue for docusaurus with react 17. |
thank you so much for the investigation + writeup @KittyGiraudel we should definitely be able to fix this -- i'd like to get for what it's worth, the demo site (also using Next) had a similar issue. I had to add these lines to the webpack config to solve it.. it might be worth seeing if that works as a temporary workaround so you can stay on |
Hello @jpdriver, |
I am using
testing with this react: const LiveDemo = ({ children, scope}) => (
<LiveProvider code={children} scope={scope}>
<LiveEditor />
<LiveError />
<LivePreview />
</LiveProvider>
) putting this in my next.config.js also didn't fix it: module.exports = {
webpack (config) {
config.resolve.alias.react = path.resolve('./node_modules/react')
config.resolve.alias['react-dom'] = path.resolve('./node_modules/react-dom')
return config
}
} If I downgade:
that got it running. |
Same, we had to downgrade to |
This appears to be fixed with the latest version of react-live 3.1.1 |
When copying the first snippet from the usage section and replace the provided code by the one in the gif from the top of the README, I get an "Error: Invalid hook call".
Any suggestion.
Thank you in advance.
The text was updated successfully, but these errors were encountered: