react-native: RangeError: Maximum call stack size exceeded.
Describe the bug When I try to open Storybook, the application freeze and crashes after a while. In the console it spams a lot of errors.
ERROR RangeError: Maximum call stack size exceeded.
Error: Requiring module "node_modules/core-js/internals/is-constructor.js", which threw an exception: RangeError: Maximum call stack size exceeded.
To Reproduce Steps to reproduce the behavior: Render Storybook on an iOS simulator
Expected behavior I expect to be able to use is.
Code snippets
Just did npx -p @storybook/cli sb init --type react_native
System: System: OS: macOS 13.0.1 CPU: (10) arm64 Apple M1 Pro Binaries: Node: 18.12.1 - ~/.nvm/versions/node/v18.12.1/bin/node Yarn: 1.22.19 - /opt/homebrew/bin/yarn npm: 8.19.2 - ~/.nvm/versions/node/v18.12.1/bin/npm Browsers: Safari: 16.1 npmPackages: @storybook/addon-actions: ^5.3 => 5.3.21 @storybook/addon-knobs: ^5.3 => 5.3.21 @storybook/addon-links: ^5.3 => 5.3.21 @storybook/addon-ondevice-knobs: ^5.3.26 => 5.3.26 @storybook/react-native: 5.3.25 => 5.3.25 @storybook/react-native-server: ^5.3.23 => 5.3.23
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 10
- Comments: 29 (14 by maintainers)
Commits related to this issue
- Working Storybook version This comment helped resolve it: https://github.com/storybookjs/react-native/issues/405#issuecomment-1436683333 — committed to peterfication/peak-tracker-app by peterfication a year ago
@KPS250 could you provide a reproduction? Also can you try adding sbmodern to the resolvers in metro config like this
try downgrade corejs
"core-js": "3.23.5",Can you try setting inline requires to false in your metro config?
Sbmodern resolver only works for storybook 6.5+, try using the 6.5 release candidate with
npx sb@next init --type react_native@CatWithNineLives turning off inline requires shouldn’t be needed anymore in v6.5 you can use the other fix with sbmodern outlined above.
The problem relates to the polyfills being used in storybook core v6 and below (removed in v7).
Probably by turning on inline requires it changes the behaviour of some code. Polyfills usually need to execute first so maybe an import got placed later or removed by the transform.
@hduoc2003 this is because storybook exports multiple different module types (commonjs, esm etc) and sbmodern is a modern output without transpilation.
By putting sbmodern as the first one in the list then we resolve those modules instead of the commonjs output for example.
in the past polyfills from corejs in storybook have caused errors with react native which is why we try to resolve sbmodern
@Mazztwo sbmodern is the fix but it only works on version 6 not on version 5.3.
@osvaguillen thats no longer the suggested fix, you can enable inline requires if you just set the resolvers like I mentioned here:
https://github.com/storybookjs/react-native/issues/405#issuecomment-1436683333
I explained the same issue here: https://github.com/storybookjs/react-native/issues/405#issuecomment-1501154722
The short answer is that polyfilled code from storybook core would break things. We use the resolver config option to resolve a more modern build of storybook core.
@rodgomesc Thank you for sharing, I chose the same way and upgraded to 6.0.1-beta
i’m using this lib for quite a few months, and after my
yarn.lockget upgraded in one PR i fall in to that issue, tried to walk through the changes but it was huge and i got lost , after double check everything in documentation it didn’t worked, also compared with https://github.com/dannyhw/expo-storybook-starter everything was in place except for the lib versions, so after use same lib versions asexpo-storybook-starterit workedthat’s my diff, hope this work for you as well