使用反应导航创建反应应用程序
create-react-app with react-navigation
我已经从 create-react-app 创建了一个应用程序并且运行良好。
当我添加 react-navitation 我得到这个错误:
./node_modules/react-navigation/src/routers/StackActions.js
Module parse failed: Unexpected token (10:2)
You may need an appropriate loader to handle this file type.
| const pop = payload => ({
| type: POP,
| ...payload,
| });
|
看来我们没有"transform-object-rest-spread" babel 插件。有人知道我该如何添加吗?
这是我在里面的依赖项 package.json:
"dependencies": {
"react": "^16.4.1",
"react-dom": "^16.4.1",
"react-navigation": "^2.6.2",
"react-scripts": "1.1.4"
}
来自本期:https://github.com/react-navigation/react-navigation/issues/3516
we don't explicitly support web or reactxp currently. if you'd like to submit a RFC for how we could do that and own it, it would be nice. it's not a priority right now. so this is more of a feature request than a bug. sorry :(
另请参阅他们的文档 this section。
TL;DR -- 他们发布了未转译的代码,并以 React Native 为目标。我建议寻找替代方案,例如久经考验的 react-router, or a newer one from one of the original authors, reach-router.
React Navigation 最近发布了一个新的更新,支持 react-navigation
和 create-react-app
Starting in v3, React Navigation has built-in support for web sites, including server rendering.
在他们的文档中查看更多详细信息here。
我已经从 create-react-app 创建了一个应用程序并且运行良好。 当我添加 react-navitation 我得到这个错误:
./node_modules/react-navigation/src/routers/StackActions.js
Module parse failed: Unexpected token (10:2)
You may need an appropriate loader to handle this file type.
| const pop = payload => ({
| type: POP,
| ...payload,
| });
|
看来我们没有"transform-object-rest-spread" babel 插件。有人知道我该如何添加吗?
这是我在里面的依赖项 package.json:
"dependencies": {
"react": "^16.4.1",
"react-dom": "^16.4.1",
"react-navigation": "^2.6.2",
"react-scripts": "1.1.4"
}
来自本期:https://github.com/react-navigation/react-navigation/issues/3516
we don't explicitly support web or reactxp currently. if you'd like to submit a RFC for how we could do that and own it, it would be nice. it's not a priority right now. so this is more of a feature request than a bug. sorry :(
另请参阅他们的文档 this section。
TL;DR -- 他们发布了未转译的代码,并以 React Native 为目标。我建议寻找替代方案,例如久经考验的 react-router, or a newer one from one of the original authors, reach-router.
React Navigation 最近发布了一个新的更新,支持 react-navigation
和 create-react-app
Starting in v3, React Navigation has built-in support for web sites, including server rendering.
在他们的文档中查看更多详细信息here。