If I run npx create-react-app myapp and then plasmic sync --p <MyProjectId> and then modify the App.js to:
import Homepage from './components/Homepage';
function App() {
return (
<div className="App">
<Homepage/>
</div>
);
}
export default App;
and then I ran yarn start it will give these Error:
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://reactjs.org/link/invalid-hook-call> for tips about how to debug and fix this problem.
at resolveDispatcher (<anonymous>:28553:13)
at useContext (<anonymous>:28561:20)
at Module.useDataEnv (<anonymous>:346:66)
at PlasmicHomepage__RenderFunc (<anonymous>:82871:126)
at func (<anonymous>:82928:16)
at renderWithHooks (<anonymous>:66944:18)
at mountIndeterminateComponent (<anonymous>:69770:13)
at beginWork (<anonymous>:71008:16)
at HTMLUnknownElement.callCallback (<anonymous>:55904:14)
at Object.invokeGuardedCallbackDev (<anonymous>:55953:16)
react-dom.development.js:20085 The above error occurred in the <PlasmicHomepage> component:
at func (<anonymous>:82922:125)
at Homepage_ (<anonymous>:82443:111)
at div
at App (<anonymous>:82298:14)
Consider adding an error boundary to your tree to customize error handling behavior.
Visit <https://reactjs.org/link/error-boundaries> to learn more about error boundaries.
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://reactjs.org/link/invalid-hook-call> for tips about how to debug and fix this problem.
at resolveDispatcher (<anonymous>:28553:13)
at useContext (<anonymous>:28561:20)
at Module.useDataEnv (<anonymous>:346:66)
at PlasmicHomepage__RenderFunc (<anonymous>:82871:126)
at func (<anonymous>:82928:16)
at renderWithHooks (<anonymous>:66944:18)
at mountIndeterminateComponent (<anonymous>:69770:13)
at beginWork (<anonymous>:71008:16)
at HTMLUnknownElement.callCallback (<anonymous>:55904:14)
at Object.invokeGuardedCallbackDev (<anonymous>:55953:16)
Next.js works fine, just regular react gives these errors, please let me know if there’s a fix
PS: I’ve tried this on all plasmic projects, old or new, they give the same error
Got it, my case I never have “plasmic/host” in package.json (it won’t be added through the CLI), once I added this line "plasmic/host":"*" it starts working again YAY
Oh, great! CLI >= 0.1.181 is asking you to install @plasmicapp/host, but I think we’re not requiring that version in the server. We will improve it! Thank you for reporting!