react-native - 如何解决模块解析失败 : Unexpected token (11:9) react-router-native

标签 react-native react-router-native

我使用 yarn 安装了 react-native-router 并且只是在导入 NativeRouter

这就是我从 react-router-native 导入的方式
从“react-router-native”导入 { NativeRouter, Route, Link };

这是我得到的错误

D:/WORKSHOP/Tunga/music-app/node_modules/react-router-native/NativeRouter.js 11:9
Module parse failed: Unexpected token (11:9)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|  */
| function NativeRouter(props) {
>   return <MemoryRouter {...props} />;
| }
|

最佳答案

有同样的错误。通过添加修复:

"web": {
  "build": {
    "babel": {
      "include": ["react-router-native"]
    }
  }
}

到 app.json

发件人:source

关于react-native - 如何解决模块解析失败 : Unexpected token (11:9) react-router-native,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61159915/

相关文章:

javascript - 运行 navigator.pop() 后如何刷新 React 状态?

javascript - 防止重新渲染数组映射组件

react-native - 想要通过单击时 react native 引用来更改不透明度

react-native - 使用 React-Router-Native 从 React Native 中的 Axios 拦截器(组件外部)重定向到 View 组件

javascript - React Native Router - 元素类型无效

react-native - 如何使用 NativeBase 组件添加事件

firebase - @react-native-firebase 破坏单元测试

animation - 是否可以为 react-router-native 应用动画?

android - React-router-native AndroidBackButton 没有触发