Skip to content

[Bug] storybook try to load native code in web mode #46

Open
@StarHosea

Description

@StarHosea

image


"@storybook/addon-essentials": "6.5.13",
"@storybook/addon-links": "6.5.13",
"@storybook/addon-ondevice-actions": "6.0.1-beta.10",
"@storybook/addon-ondevice-backgrounds": "6.0.1-beta.10",
"@storybook/addon-ondevice-controls": "6.0.1-beta.10",
"@storybook/addon-ondevice-notes": "6.0.1-beta.10",
"@storybook/react-native": "6.0.1-beta.10",
"@storybook/addon-react-native-web": "0.0.19",
"@storybook/react": "6.5.13",
"@storybook/docs-tools": "6.5.13"

  • .storybook main.js
const path = require('path');
module.exports = {
  staticDirs: ['./public'],
  stories: [
    "../src/**/*.stories.mdx",
    "../src/**/*.stories.@(js|jsx|ts|tsx)",
  ],
  addons: [
    "@storybook/addon-links",
    "@storybook/addon-essentials",
    "@storybook/addon-react-native-web",
  ],
  framework: "@storybook/react",
  features: {
    storyStoreV7: true,
  },
  webpackFinal: async (config, { configType })=>{
    // Make whatever fine-grained changes you need
    // Return the altered config
    return config;
  }
};

tw-map-view folder like this

tw-map-view/
     __stories__
           index.stories.tsx
    index.ts
    TwMapView.native.tsx: which contains  native platform code
    TwMapView.tsx:  which only has web platform code
  • index.stories.tsx
import { TwMapView, TwMapViewSdk } from '../TwMapView';
export default {
  title: 'display/tw-map-view',
  component: TwMapView,
  parameters: {
    actions: { argTypesRegex: '^on.*' },
    docs: {
    },
  },
};
....some other code

I try some steps

  • delte TwMapView.native.tsx ,restart storybook , works fine
  • rename TwMapView to TwMapView.web.ts, rename TwMapView.native.tsx to TwMapView.tsx, storybook will break while loading TwMapview.tsx

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions