Closed Awethentique closed 1 year ago
@Awethentique can you try adding @bang88/react-native-ultimate-listview to the modules to transpile list, it seems to be the problematic library
Thank you for that find.
Adding '@bang88/react-native-ultimate-listview'
to the modulesToTranspile
seems to resolve the error from the Storybook canvas.
I now get this error:
I tried adding the config for the warning, but this only loads weback to 57% and hangs.
`module.exports = {
addons: [
/*existing addons,*/
{
name: '@storybook/addon-react-native-web',
options: {
modulesToTranspile: ['react-native-reanimated'],
babelPlugins: ['react-native-reanimated/plugin'],
},
},
],
};
Not sure what you mean about the config for the warning, could you clarify?
in the previous screenshot, I had this warning:
I thought that might be because I need to add in this:
This caused webpack to hang at 57% Buiding.
@Awethentique well it looks like its actually complaining about reanimated not being installed, do you have reanimated installed on the project too?
If you add it you also might need this babel plugin for reanimated "@babel/plugin-proposal-export-namespace-from",
so like:
options: {
modulesToTranspile: ['react-native-reanimated'],
babelPlugins: ['@babel/plugin-proposal-export-namespace-from', 'react-native-reanimated/plugin'],
},
plus what ever other config. (note that react-native-reanimated/plugin should be last)
For anyone else stumbling across this setting up Ant design and Storybook with this add-on.
There was no need to do anything for reanimated.
I spent some time again with this. I finally got it to work using the following:
I had to install yarn add -D babel-plugin-module-resolver babel-plugin-import
To the babel.config.js I added:
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
plugins: [
[
'module-resolver',
{
extensions: ['.js', '.jsx', '.ts', '.tsx', '.ios.js', '.android.js'],
root: ['./src'],
alias: {
'~': './src',
},
},
'root-alias',
],
[
'import',
{
libraryName: '@ant-design/react-native',
},
],
],
};
All is working fine
The repo that I cloned above has been updated with the necessary changes committed.
Describe the bug
A clear and concise description of what the bug is.
ant-design-mobile-rn - Supports web and native usages based on React Native. The package is working fine on a device but not on the web implementation with Storybook using "addon-react-native-web".
I cloned the repo from https://github.com/dannyhw/react-native-storybook-starter and followed the "getting started" guide I added the @ant-design/react-native library as per the instructions on https://github.com/ant-design/ant-design-mobile-rn
I have also tried with and without updating the .storybook/main.js:
When I run
yarn storybook
I get the errors described in the errors section of this post.It seems like for some reason it's trying to load something from camera-roll which is not even being used by the button component. This works fine when running on a device with no errors.
To make it easier: I forked the starter repo and created a minimalistic reproduction here on the main branch with the packages and example component: https://github.com/Awethentique/react-native-storybook-starter
Steps to reproduce the behaviour
yarn install
to install the packagesyarn storybook
to start the projectExpected behaviour
I would expect to see the ant-design-mobile-rn button to work on both the web view and the mobile device with no errors.
Screenshots and/or logs
I get this error in the canvas:
and this error in the Devtools console:
Additional context
For most of the errors I encountered, I could not find any related solutions on the web. I could not find working boilerplate examples of this package with Storybook as well.
Any help finding a way to get this working will be very appreciated. Thanks!