Skip to content

When react compiler is enabled - ERROR: [TypeError: ks is not a function (it is undefined)]  #732

@the-simian

Description

@the-simian

Describe the bug
Storybook Android:
ERROR [TypeError: ks is not a function (it is undefined)]

To Reproduce
When running the following versions you will get this error on the storybook-mobile build, when the same versions work on storybook-web
package.json

    "@storybook/addon-essentials": "8.6.14",
    "@storybook/addon-ondevice-actions": "^8.6.2",
    "@storybook/addon-ondevice-backgrounds": "^8.6.2",
    "@storybook/addon-ondevice-controls": "^8.6.2",
    "@storybook/addon-ondevice-notes": "^8.6.2",
    "@storybook/core": "8.6.14",
    "@storybook/react": "8.6.14",
    "@storybook/react-native": "^8.6.2",
    "@storybook/react-native-web-vite": "8.6.14",
     "storybook": "8.6.14",

metro.config.ts

const path = require('node:path');
const { getDefaultConfig } = require('expo/metro-config');
const withStorybook = require('@storybook/react-native/metro/withStorybook');
const { getSentryExpoConfig } = require('@sentry/react-native/metro');
const { withNativeWind } = require('nativewind/metro');

const STORYBOOK_ENABLED =
  process.env.STORYBOOK_ENABLED === 'true' || process.env.STORYBOOK_ENABLED === true;

let config = getDefaultConfig(__dirname);

//Note: Including this since I do use Sentry, but removing this makes no difference
if (!STORYBOOK_ENABLED) {
  config = getSentryExpoConfig(__dirname);
}

config = withNativeWind(config, { input: './global.css' });

config = withStorybook(config, {
  enabled: STORYBOOK_ENABLED,
  onDisabledRemoveStorybook: !STORYBOOK_ENABLED,
  configPath: path.resolve(__dirname, './.storybook-mobile'),
});

module.exports = config;

Expected behavior
This issue occurs at runtime, and emmits the 'red screen' React Native Error, instead of loading the storybook instance

Screenshots

Red Screen
Image

System:

Storybook Environment Info:

  System:
    OS: Linux 5.15 Ubuntu 22.04.5 LTS 22.04.5 LTS (Jammy Jellyfish)
    CPU: (18) x64 13th Gen Intel(R) Core(TM) i9-13900K
    Shell: 5.8.1 - /usr/bin/zsh
  Binaries:
    Node: 22.4.0 - ~/.nvm/versions/node/v22.4.0/bin/node
    Yarn: 1.22.22 - ~/.nvm/versions/node/v22.4.0/bin/yarn
    npm: 10.8.1 - ~/.nvm/versions/node/v22.4.0/bin/npm
    pnpm: 8.15.1 - ~/.local/share/pnpm/pnpm
  npmPackages:
    @storybook/addon-essentials: 8.6.14 => 8.6.14
    @storybook/addon-ondevice-actions: ^8.6.2 => 8.6.2
    @storybook/addon-ondevice-backgrounds: ^8.6.2 => 8.6.2
    @storybook/addon-ondevice-controls: ^8.6.2 => 8.6.2
    @storybook/addon-ondevice-notes: ^8.6.2 => 8.6.2
    @storybook/core: 8.6.14 => 8.6.14
    @storybook/react: 8.6.14 => 8.6.14
    @storybook/react-native: ^8.6.2 => 8.6.2
    @storybook/react-native-web-vite: 8.6.14 => 8.6.14
    @storybook/test: 8.6.14 => 8.6.14
    storybook: 8.6.14 => 8.6.14
    storybook-addon-apollo-client: ^8.1.2 => 8.1.2
    storybook-addon-deep-controls: ^0.9.2 => 0.9.2

Additional context

ks is the minified version of the isStory function from @storybook/core/csf
This function is used in processCSFFile() to validate story exports
Likely cause: Version mismatch between core Storybook packages (8.6.14) and React Native Storybook (8.6.2)
Different versions have incompatible imports/exports, causing isStory to be undefined when called as ks()

Additional Notes
The example boilerplate at https://github.com/dannyhw/expo-router-storybook runs fine, suggesting there's a dependency issue with multiple versions of storybook/core being installed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions