question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

nextjs example seems broken

See original GitHub issue

Hello,

When I try to run the last version of nextjs example, I get the following error when opening http://localhost:3001:

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 (react.development.js?aef8:1476)
    at useEffect (react.development.js?aef8:1519)
    at ExportredTitle (webpack-internal:///./components/exposedTitle.js:19)
    at renderWithHooks (react-dom.development.js?f8c1:14985)
    at mountIndeterminateComponent (react-dom.development.js?f8c1:17811)
    at beginWork (react-dom.development.js?f8c1:19049)
    at HTMLUnknownElement.callCallback (react-dom.development.js?f8c1:3945)
    at Object.invokeGuardedCallbackDev (react-dom.development.js?f8c1:3994)
    at invokeGuardedCallback (react-dom.development.js?f8c1:4056)
    at beginWork$1 (react-dom.development.js?f8c1:23964)
    at performUnitOfWork (react-dom.development.js?f8c1:22776)
    at workLoopSync (react-dom.development.js?f8c1:22707)
    at renderRootSync (react-dom.development.js?f8c1:22670)
    at performSyncWorkOnRoot (react-dom.development.js?f8c1:22293)
    at eval (react-dom.development.js?f8c1:11327)
    at unstable_runWithPriority (scheduler.development.js?bacd:468)
    at runWithPriority$1 (react-dom.development.js?f8c1:11276)
    at flushSyncCallbackQueueImpl (react-dom.development.js?f8c1:11322)
    at flushSyncCallbackQueue (react-dom.development.js?f8c1:11309)
    at scheduleUpdateOnFiber (react-dom.development.js?f8c1:21893)
    at dispatchAction (react-dom.development.js?f8c1:16139)
    at checkForUpdates (webpack-internal:///../node_modules/use-subscription/cjs/use-subscription.development.js:85)
    at eval (webpack-internal:///../node_modules/next/dist/next-server/lib/loadable.js:307)
    at Set.forEach (<anonymous>)
    at LoadableSubscription._update (webpack-internal:///../node_modules/next/dist/next-server/lib/loadable.js:306)
    at eval (webpack-internal:///../node_modules/next/dist/next-server/lib/loadable.js:286)

The above error occurred in the <ExportredTitle> component:

    at ExportredTitle (webpack-internal:///./components/exposedTitle.js:19:51)
    at LoadableComponent (webpack-internal:///../node_modules/next/dist/next-server/lib/loadable.js:188:37)
    at div
    at div
    at Home (webpack-internal:///./pages/index.js:44:21)
    at MyApp (webpack-internal:///./pages/_app.js:75:24)
    at ErrorBoundary (webpack-internal:///../node_modules/@next/react-dev-overlay/lib/internal/ErrorBoundary.js:26:47)
    at ReactDevOverlay (webpack-internal:///../node_modules/@next/react-dev-overlay/lib/internal/ReactDevOverlay.js:86:23)
    at Container (webpack-internal:///../node_modules/next/dist/client/index.js:155:5)
    at AppContainer (webpack-internal:///../node_modules/next/dist/client/index.js:643:24)
    at Root (webpack-internal:///../node_modules/next/dist/client/index.js:779:25)

React will try to recreate this component tree from scratch using the error boundary you provided, ErrorBoundary.
logCapturedError @ react-dom.development.js?f8c1:20085

Usually it means that 2 instances of React are used but Module Federation plugin is set up to share React.

Does someone know where it could come from?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
jsnordhealthcommented, Jun 1, 2022

@ScriptedAlchemy I’ve been playing around with you’re plugin (not sure if this is the right form for this kind of question) but I’ve been also experiencing the same issue. You can recreate it by in the example react-nextjs/nextjs-host-react-remote example by adding a simple useState hook in the Nav component in remote.

1reaction
donovanperaltacommented, Jul 25, 2021

@ScriptedAlchemy how much are you charging for the paid plugin, where can we read more about it?

https://app.privjs.com/buy/packageDetail?pkg=@module-federation/nextjs-mf

Read more comments on GitHub >

github_iconTop Results From Across the Web

nextjs example CSS broken in production #21800 - GitHub
Describe the bug. Home page (and probably others) in production have broken styles. To Reproduce Steps to reproduce the behavior:.
Read more >
Fix Broken Images in React with Next.js - YouTube
Learn how to create a simple fallback image component for missing or broken images using React and Next.js.
Read more >
Advanced Features: Error Handling - Next.js
Error Handling. This documentation explains how you can handle development, server-side, and client-side errors. Handling Errors in Development.
Read more >
nextjs - page style not loading initially causing huge icons and ...
I have a page that shows huge icons and pretty much broken css on page load. Followed official nextjs mui5 example.
Read more >
What's New in Next.js 13 - AppSignal Blog
In Next.js 13, you can now easily stream parts of the UI to the client with React Suspense. For example, if data fetching...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found