-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Description
Describe the bug
- I have searched other issues
Overview
Im running Storybook for React, initialized with npx storybook@latest (storybook version 7.5.2). I added support for showing React Native components in this app by extending the SB configuration with @storybook/addon-react-native-web (version 0.0.21).
Components previews (examples) work fine, but when I add tags:['autodocs'], the Documentation preview fails with the following error:
Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined.
Check the render method of `ArgsTable`.
Component and story
Simple Button component:
// Button.tsx
import React from 'react';
import { TouchableOpacity, Text } from 'react-native';
export const Button = ({title, onPress}: {title: string; onPress: ()=>void}) => {
return <TouchableOpacity onPress={onPress}>
<Text>{title}</Text>
</TouchableOpacity>
}
Simple Button story:
// Button.stories.ts
import { Button } from './Button';
const meta = {
title: 'Mobile/MyButton',
component: Button,
// When this is deleted, everything works fine
tags:['autodocs']
};
export default meta;
export const Primary = {
args: {
title: 'Primary text',
onPress: () => {
console.log('aaa');
},
},
};
export const Secondary = {
args: {
title: 'Secondary text',
},
};
Storybook configuration
// main.ts
import { join, dirname } from 'path';
import {} from '@storybook/react';
/**
* This function is used to resolve the absolute path of a package.
* It is needed in projects that use Yarn PnP or are set up within a monorepo.
*/
function getAbsolutePath(value) {
return dirname(require.resolve(join(value, 'package.json')));
}
/** @type { import('@storybook/react-webpack5').StorybookConfig } */
const config = {
stories: [
'../../../packages/components/**/*.mdx',
'../../../packages/components/**/*.stories.@(js|jsx|mjs|ts|tsx)',
],
addons: [
getAbsolutePath('@storybook/addon-links'),
getAbsolutePath('@storybook/addon-essentials'),
getAbsolutePath('@storybook/addon-onboarding'),
getAbsolutePath('@storybook/addon-interactions'),
getAbsolutePath('@storybook/addon-react-native-web')
],
framework: {
name: getAbsolutePath('@storybook/react-webpack5'),
options: {},
},
typescript: { reactDocgen: false },
docs: {
autodocs: 'tag',
},
};
export default config;
Console output
Console shows that the error is probably located in the storybook-addon-docs
To Reproduce
- Clone the Github repository
- Run
npm install
- Run
npm run storybook
System
System:
OS: macOS 13.1
CPU: (10) arm64 Apple M1 Max
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 18.17.1 - ~/.nvm/versions/node/v18.17.1/bin/node
Yarn: 1.22.19 - /opt/homebrew/bin/yarn
npm: 9.6.7 - ~/.nvm/versions/node/v18.17.1/bin/npm <----- active
pnpm: 8.6.1 - ~/Library/pnpm/pnpm
Browsers:
Chrome: 119.0.6045.105
Safari: 16.2
npmPackages:
@storybook/addon-react-native-web: ^0.0.21 => 0.0.21
Additional context
No response
Metadata
Metadata
Assignees
Type
Projects
Status