storybook: v6.2.0-alpha.16 - "init is not a function"
Upon starting, the storybook renders an empty screen with the following error in the console:
Uncaught TypeError: init is not a function
at mountLazyComponent (vendors~main.041dab005b25a81e4fed.bundle.js:128889)
at beginWork (vendors~main.041dab005b25a81e4fed.bundle.js:130282)
at HTMLUnknownElement.callCallback (vendors~main.041dab005b25a81e4fed.bundle.js:115172)
at Object.invokeGuardedCallbackDev (vendors~main.041dab005b25a81e4fed.bundle.js:115221)
at invokeGuardedCallback (vendors~main.041dab005b25a81e4fed.bundle.js:115283)
at beginWork$1 (vendors~main.041dab005b25a81e4fed.bundle.js:135186)
at performUnitOfWork (vendors~main.041dab005b25a81e4fed.bundle.js:133998)
at workLoopSync (vendors~main.041dab005b25a81e4fed.bundle.js:133929)
at renderRootSync (vendors~main.041dab005b25a81e4fed.bundle.js:133892)
at performSyncWorkOnRoot (vendors~main.041dab005b25a81e4fed.bundle.js:133515)
vendors~main.041dab005b25a81e4fed.bundle.js:131312 The above error occurred in one of your React components:
at Lazy
at Suspense
at Scroller (http://localhost:6006/vendors~main.041dab005b25a81e4fed.bundle.js:21270:25)
at render
at nav
at render
at http://localhost:6006/vendors~main.041dab005b25a81e4fed.bundle.js:39418:29
at ManagerConsumer (http://localhost:6006/vendors~main.041dab005b25a81e4fed.bundle.js:9720:28)
at div
at render
at Sidebar (http://localhost:6006/vendors~main.041dab005b25a81e4fed.bundle.js:33866:28)
at Layout (http://localhost:6006/vendors~main.041dab005b25a81e4fed.bundle.js:34048:5)
at render
at http://localhost:6006/vendors~main.041dab005b25a81e4fed.bundle.js:34404:20
at div
at render
at http://localhost:6006/vendors~main.041dab005b25a81e4fed.bundle.js:33576:23
at SizeMeReferenceWrapper (http://localhost:6006/vendors~main.041dab005b25a81e4fed.bundle.js:143326:5)
at SizeMeRenderer(Component) (http://localhost:6006/vendors~main.041dab005b25a81e4fed.bundle.js:143379:29)
at SizeMe(Component) (http://localhost:6006/vendors~main.041dab005b25a81e4fed.bundle.js:143460:9)
at ThemeProvider
at http://localhost:6006/vendors~main.041dab005b25a81e4fed.bundle.js:41760:25
at ManagerConsumer (http://localhost:6006/vendors~main.041dab005b25a81e4fed.bundle.js:9720:28)
at EffectOnMount (http://localhost:6006/vendors~main.041dab005b25a81e4fed.bundle.js:9707:24)
at Manager (http://localhost:6006/vendors~main.041dab005b25a81e4fed.bundle.js:9566:5)
at Location (http://localhost:6006/vendors~main.041dab005b25a81e4fed.bundle.js:4806:23)
at QueryLocation (http://localhost:6006/vendors~main.041dab005b25a81e4fed.bundle.js:32015:24)
at LocationProvider (http://localhost:6006/vendors~main.041dab005b25a81e4fed.bundle.js:4826:5)
at HelmetProvider (http://localhost:6006/vendors~main.041dab005b25a81e4fed.bundle.js:139518:5403)
at Root (http://localhost:6006/vendors~main.041dab005b25a81e4fed.bundle.js:41742:23)
React will try to recreate this component tree from scratch using the error boundary you provided, LocationProvider.
logCapturedError @ vendors~main.041dab005b25a81e4fed.bundle.js:131312
vendors~main.041dab005b25a81e4fed.bundle.js:4852 Uncaught TypeError: init is not a function
at mountLazyComponent (vendors~main.041dab005b25a81e4fed.bundle.js:128889)
at beginWork (vendors~main.041dab005b25a81e4fed.bundle.js:130282)
at HTMLUnknownElement.callCallback (vendors~main.041dab005b25a81e4fed.bundle.js:115172)
at Object.invokeGuardedCallbackDev (vendors~main.041dab005b25a81e4fed.bundle.js:115221)
at invokeGuardedCallback (vendors~main.041dab005b25a81e4fed.bundle.js:115283)
at beginWork$1 (vendors~main.041dab005b25a81e4fed.bundle.js:135186)
at performUnitOfWork (vendors~main.041dab005b25a81e4fed.bundle.js:133998)
at workLoopSync (vendors~main.041dab005b25a81e4fed.bundle.js:133929)
at renderRootSync (vendors~main.041dab005b25a81e4fed.bundle.js:133892)
at performSyncWorkOnRoot (vendors~main.041dab005b25a81e4fed.bundle.js:133515)
vendors~main.041dab005b25a81e4fed.bundle.js:131312 The above error occurred in the <LocationProvider> component:
at LocationProvider (http://localhost:6006/vendors~main.041dab005b25a81e4fed.bundle.js:4826:5)
at HelmetProvider (http://localhost:6006/vendors~main.041dab005b25a81e4fed.bundle.js:139518:5403)
at Root (http://localhost:6006/vendors~main.041dab005b25a81e4fed.bundle.js:41742:23)
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.
logCapturedError @ vendors~main.041dab005b25a81e4fed.bundle.js:131312
vendors~main.041dab005b25a81e4fed.bundle.js:122567 Uncaught TypeError: init is not a function
at mountLazyComponent (vendors~main.041dab005b25a81e4fed.bundle.js:128889)
at beginWork (vendors~main.041dab005b25a81e4fed.bundle.js:130282)
at HTMLUnknownElement.callCallback (vendors~main.041dab005b25a81e4fed.bundle.js:115172)
at Object.invokeGuardedCallbackDev (vendors~main.041dab005b25a81e4fed.bundle.js:115221)
at invokeGuardedCallback (vendors~main.041dab005b25a81e4fed.bundle.js:115283)
at beginWork$1 (vendors~main.041dab005b25a81e4fed.bundle.js:135186)
at performUnitOfWork (vendors~main.041dab005b25a81e4fed.bundle.js:133998)
at workLoopSync (vendors~main.041dab005b25a81e4fed.bundle.js:133929)
at renderRootSync (vendors~main.041dab005b25a81e4fed.bundle.js:133892)
at performSyncWorkOnRoot (vendors~main.041dab005b25a81e4fed.bundle.js:133515)
┆Issue is synchronized with this Asana task by Unito
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 22 (8 by maintainers)
If anyone els end up here after googling the error (like me): Uncaught TypeError: init is not a function
It seam to be caused by miss matched React versions. so just check your deps with npm list or yarn list to make sure you’ve not ended up with conflicting react versions.
Had a component lib based on React 17 and my storybook project had a React 16 dep.
I reproduced this error. I have a workspace in which both React17 and React16 and ReactDOM16 and ReactDOM17 are installed. The implementation of
React.lazyhas changed. React16.13 has no init property,but React16.14 and React17 has init property.https://github.com/facebook/react/blob/v16.13.1/packages/react/src/ReactLazy.js#L13 https://github.com/facebook/react/blob/v16.14.0/packages/react/src/ReactLazy.js#L110
https://github.com/facebook/react/blob/fc33f12bdee1d0ffbcc83d25199cdf4d47252736/packages/react-reconciler/src/ReactFiberBeginWork.old.js#L1289 https://github.com/facebook/react/blob/v16.13.1/packages/react-reconciler/src/ReactFiberBeginWork.js#L1115
BUT in pkg React16.14,the
React.lazyfunction in the dist file react.development.js has no init property.I think maybe this is a bug about React16.14.
I am getting the same issue with 6.2.x. I downgraded to 6.1.x and problem gone.