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.

v6.2.0-alpha.16 - "init is not a function"

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:20 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
ccromnowcommented, Oct 5, 2021

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.

2reactions
gavinxgucommented, May 6, 2021

I reproduced this error. I have a workspace in which both React17 and React16 and ReactDOM16 and ReactDOM17 are installed. The implementation of React.lazy has 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.lazy function in the dist file react.development.js has no init property.

I think maybe this is a bug about React16.14.

Read more comments on GitHub >

github_iconTop Results From Across the Web

react-dom 17.0.0 update error TypeError: init is not a function
Updating react-dom from 16.3 to 17.0.0 in my CRA, getting the following error once I upgrade react-dom. Have had no previous issues updating ......
Read more >
MIGRATION.md · Gitee 极速下载/storybook - Gitee.com
The RenderContext that is passed to framework rendering layers in order to render a story has been simplified, dropping a few members that...
Read more >
'init is not a function' while React Codesplitting : r/reactjs - Reddit
I have 'init is not a function error when I try to do codesplit. I have a folder named 'Pages' which has index....
Read more >
cli.init is not a function || React native initiation error easy fix
The error:TypeError: cli. init is not a functionat run (/Users/user/.config/yarn/global/node_modules/react-native-cli/index.js:302:7)at ...
Read more >
Lightning calling helper function returns not a function in init
your Controller Should be ({ doInit: function(component, event, helper) { helper.runSetup(); } }). Actually you have interchanged the ...
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