1

I need to add {"plugins": [["import", { "libraryName": "antd-mobile" }]]} to .babelrc from a project generated by create-react-native-app to make ant-design-mobile work in react native.

I have started a new project with create-react-native-app. Change the .babelrc to this:

 {
  "presets": ["babel-preset-expo"],
  "env": {
    "development": {
      "plugins": [
        "transform-react-jsx-source",
      ]
    }
  },
  "plugins": [
    ["import", { "libraryName": "antd-mobile" }]
  ]
}

Class:

import { Button } from 'antd-mobile';

export class Screen extends React.Component<any,{}>{
   render(){
     return(
            <View>
                <Button>Something</Button>
            </View>
        )
   }
}

However, I'm still getting this error on start:

Note: must use https://github.com/ant-design/babel-plugin-import .
For more information, please see https://github.com/ant-design/ant-design-mobile/issues/602

Can anyone point me to a solution?

RedGiant
  • 4,444
  • 11
  • 59
  • 146

1 Answers1

0

You can take a look at official react-native app demo: https://github.com/ant-design/antd-mobile-samples/tree/master/react-native

paranoidjk
  • 41
  • 1
  • thanks . The problem seems to be that I have to run `eject` in order to use `babel-plugin-import` for projects generated by `create-react-native-app`, which is something I want to avoid. – RedGiant May 17 '17 at 14:24