'Storybook react native (IOS) - RangeError: Maximum call stack size exceeded (native stack depth)

For IOS - got this error while setting up storybook for current react native app in IOS .using RN 0.66.1 version, using "@storybook/react-native": "^5.3.25",

storybook/index.js -

// if you use expo remove this line
import { AppRegistry } from 'react-native';

import { getStorybookUI, configure, addDecorator } from '@storybook/react-native';
import { withKnobs } from '@storybook/addon-knobs';

import './rn-addons';

// enables knobs for all stories
addDecorator(withKnobs);

// import stories
configure(() => {
  require('./stories');
}, module);

// Refer to https://github.com/storybookjs/react-native/tree/master/app/react-native#getstorybookui-options
// To find allowed options for getStorybookUI
const StorybookUIRoot = getStorybookUI({});

// If you are using React Native vanilla and after installation you don't see your app name here, write it manually.
// If you use Expo you should remove this line.
AppRegistry.registerComponent('%APP_NAME%', () => StorybookUIRoot);

export default StorybookUIRoot;


Solution 1:[1]

I noticed this error occurs if you are using the Hermes engine for whatever reason. If you disable the Hermes engine, you should be able to use Storybook. Note that you may want to enable the Hermes engine for production though. To enable/disable Hermes for ios, it should be in the Podfile and for android in android/app/build.gradle

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ChrisF582