Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs Expo CLI中的react路由器本机给定错误-react本机_Reactjs_React Native_React Router_Expo Cli_React Router Native - Fatal编程技术网

Reactjs Expo CLI中的react路由器本机给定错误-react本机

Reactjs Expo CLI中的react路由器本机给定错误-react本机,reactjs,react-native,react-router,expo-cli,react-router-native,Reactjs,React Native,React Router,Expo Cli,React Router Native,我已使用npm在我的项目中安装了react router native,我收到一个错误,错误是: E:/myapp/node_modules/react router native/NativeRouter.js, 11:9模块分析失败:意外令牌(11:9)。。。。你可能需要一个 处理此文件类型的适当加载程序,目前没有加载程序 已配置为处理此文件。看见 package.json: { "main": "node_modules/expo/AppEntry.js

我已使用npm在我的项目中安装了react router native,我收到一个错误,错误是:

E:/myapp/node_modules/react router native/NativeRouter.js, 11:9模块分析失败:意外令牌(11:9)。。。。你可能需要一个 处理此文件类型的适当加载程序,目前没有加载程序 已配置为处理此文件。看见

package.json:

{
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "eject": "expo eject"
  },
  "dependencies": {
    "@material-ui/core": "^4.11.2",
    "expo": "~40.0.0",
    "expo-status-bar": "~1.0.3",
    "firebase": "^8.2.0",
    "react": "16.13.1",
    "react-dom": "16.13.1",
    "react-native": "https://github.com/expo/react-native/archive/sdk-40.0.1.tar.gz",
    "react-native-vector-icons": "^7.1.0",
    "react-native-web": "~0.13.12",
    "react-router-native": "^5.2.0"
  },
  "devDependencies": {
    "@babel/core": "~7.9.0"
  },
  "private": true
}
import React from "react";
import { Alert } from "react-native";
import { MemoryRouter } from "react-router";
import PropTypes from "prop-types";

/**
 * The public API for a <Router> designed for React Native. Gets
 * user confirmations via Alert by default.
 */
function NativeRouter(props) {
  return <MemoryRouter {...props} />;
}

NativeRouter.defaultProps = {
  getUserConfirmation: (message, callback) => {
    Alert.alert("Confirm", message, [
      { text: "Cancel", onPress: () => callback(false) },
      { text: "OK", onPress: () => callback(true) }
    ]);
  }
};

const __DEV__ = true; // TODO

if (__DEV__) {
  NativeRouter.propTypes = {
    initialEntries: PropTypes.array,
    initialIndex: PropTypes.number,
    getUserConfirmation: PropTypes.func,
    keyLength: PropTypes.number,
    children: PropTypes.node
  };
}

export default NativeRouter;
react router native所在的文件出现错误(NativeRouter.js):

{
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "eject": "expo eject"
  },
  "dependencies": {
    "@material-ui/core": "^4.11.2",
    "expo": "~40.0.0",
    "expo-status-bar": "~1.0.3",
    "firebase": "^8.2.0",
    "react": "16.13.1",
    "react-dom": "16.13.1",
    "react-native": "https://github.com/expo/react-native/archive/sdk-40.0.1.tar.gz",
    "react-native-vector-icons": "^7.1.0",
    "react-native-web": "~0.13.12",
    "react-router-native": "^5.2.0"
  },
  "devDependencies": {
    "@babel/core": "~7.9.0"
  },
  "private": true
}
import React from "react";
import { Alert } from "react-native";
import { MemoryRouter } from "react-router";
import PropTypes from "prop-types";

/**
 * The public API for a <Router> designed for React Native. Gets
 * user confirmations via Alert by default.
 */
function NativeRouter(props) {
  return <MemoryRouter {...props} />;
}

NativeRouter.defaultProps = {
  getUserConfirmation: (message, callback) => {
    Alert.alert("Confirm", message, [
      { text: "Cancel", onPress: () => callback(false) },
      { text: "OK", onPress: () => callback(true) }
    ]);
  }
};

const __DEV__ = true; // TODO

if (__DEV__) {
  NativeRouter.propTypes = {
    initialEntries: PropTypes.array,
    initialIndex: PropTypes.number,
    getUserConfirmation: PropTypes.func,
    keyLength: PropTypes.number,
    children: PropTypes.node
  };
}

export default NativeRouter;
从“React”导入React;
从“react native”导入{Alert};
从“react路由器”导入{MemoryRouter};
从“道具类型”导入道具类型;
/**
*为React本机设计的公共API。得到
*默认情况下,通过警报进行用户确认。
*/
功能NativeRouter(道具){
返回;
}
NativeRouter.defaultProps={
getUserConfirmation:(消息,回调)=>{
警报。警报(“确认”),消息[
{文本:“取消”,onPress:()=>回调(false)},
{文本:“确定”,onPress:()=>回调(true)}
]);
}
};
常数_DEV__=true;//待办事项
如果(开发){
NativeRouter.propTypes={
initialEntries:PropTypes.array,
initialIndex:PropTypes.number,
getUserConfirmation:PropTypes.func,
keyLength:PropTypes.number,
子项:PropTypes.node
};
}
导出默认的NativeRouter;

安装
反应导航
,我认为您需要
巴别塔预设博览会
pacakge@NishargShah,是否与react路由器本机相同?请在回答中解释。no react router native是一个不同的包,通常用于react,但react navigation是react的一个很棒的包-native@NishargShah,我刚刚安装了它,它完全不同。安装
react导航
,它更好我想你需要
babel预设博览会
pacakge@NishargShah,它与react路由器本机相同吗?请在回答中解释。no react router native是一个不同的包,通常用于react,但react navigation是react的一个很棒的包-native@NishargShah,我刚刚安装了它,它完全不同。