storybookjs / react-native

📓 Storybook for React Native!
https://storybook.js.org
MIT License
996 stars 141 forks source link

Wrong import pass for "argsEnhancers" #497

Closed Gorb1k closed 11 months ago

Gorb1k commented 11 months ago

Describe the bug

If you are using "@storybook/react-native": "^6.5.4" with last version "@storybook/addon-actions": "^7.0.26", where is a wrong import for argsEnhancers in autogenerated storybook.requires.js

Must be import { argsEnhancers } from "@storybook/addon-actions" instead of import { argsEnhancers } from "@storybook/addon-actions/dist/modern/preset/addArgs"

To Reproduce

Steps to reproduce the behavior:

  1. Add @storybook/addon-ondevice-actions to addons array in main.js
  2. Add this script to your package.json "storybook-generate": "sb-rn-get-stories"
  3. Run yarn storybook-generate
  4. Start storybook app
  5. See an error

Expected behavior

An app is working

Code snippets

Path: scripts/loader (132 line)

 // TODO: implement presets or something similar
  if (main.addons.includes('@storybook/addon-ondevice-actions')) {
    enhancersImport =
      'import { argsEnhancers } from "@storybook/addon-actions/dist/modern/preset/addArgs"';

    // try/catch is a temporary fix for https://github.com/storybookjs/react-native/issues/327 until a fix is found
    enhancers = `
      try {
        argsEnhancers.forEach(enhancer => addArgsEnhancer(enhancer));
      } catch{}
    `;
  }

System:

System: OS: macOS 13.4.1 CPU: (10) arm64 Apple M1 Pro Binaries: Node: 18.13.0 Yarn: 1.22.19 npm: 8.19.4 Browsers: Chrome: 114.0.5735.198 Safari: 16.5.1 npmPackages: @storybook/addon-actions: ^7.0.26 => 7.0.26 @storybook/addon-controls: ^7.0.26 => 7.0.26 @storybook/addon-links: ^7.0.26 => 7.0.26 @storybook/addon-ondevice-actions: ^6.5.4 => 6.5.4 @storybook/addon-ondevice-controls: ^6.5.4 => 6.5.4 @storybook/addons: ^7.0.26 => 7.0.26 @storybook/core-common: ^7.0.27 => 7.0.27 @storybook/react-native: ^6.5.4 => 6.5.4 @storybook/react-native-server: ^6.5.4 => 6.5.4

dannyhw commented 11 months ago

Version 7 isn't compatible with version 6.5, Better to downgrade the v7 to v6.5. Major versions are breaking changes so things can be broken when trying to mix versions.

Gorb1k commented 11 months ago

Thank you!