Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/467.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
Javascript Can';t组件中的访问模块将安装_Javascript_Reactjs_React Native_Ecmascript 6 - Fatal编程技术网

Javascript Can';t组件中的访问模块将安装

Javascript Can';t组件中的访问模块将安装,javascript,reactjs,react-native,ecmascript-6,Javascript,Reactjs,React Native,Ecmascript 6,我在/src/utils/errorPopup.js import { Toast } from 'native-base'; export default function errorPopup(problem = 'process your request') { Toast.show({ text: `Unfortunately we cannot ${problem}. An error report has been created and we will look in

我在
/src/utils/errorPopup.js

import { Toast } from 'native-base';

export default function errorPopup(problem = 'process your request') {
  Toast.show({
    text: `Unfortunately we cannot ${problem}. An error report has been created and we will look into it shortly. Please get in touch with us if the problem doesn't disappear in the next 6 business hours.`,
    position: 'bottom',
    buttonText: 'Okay'
  });
}
然后我尝试在
/src/components/JobList.js的
组件willmount
方法中调用它,它说
未捕获引用错误:未定义错误弹出窗口

import React, { Component } from 'react';
import { View } from 'react-native';
import axios from 'axios';
import errorPopup from '../utils/errorPopup';

export default class JobsList extends Component {
  constructor() {
    super();
    this.state = {
      someObject: undefined
    };
  }

  componentWillMount() {
    axios.get('http://api.test.dev:5000/')
    .then(response => {
      this.setState({ someObject: response.data })
    })
    .catch(() => {
      errorPopup('fetch your accepted and available jobs');
    });
  }

  render() {
    return (
      <View />
    );
  }
}
import React,{Component}来自'React';
从“react native”导入{View};
从“axios”导入axios;
从“../utils/errorPopup”导入errorPopup;
导出默认类作业列表扩展组件{
构造函数(){
超级();
此.state={
someObject:未定义
};
}
组件willmount(){
axios.get()http://api.test.dev:5000/')
。然后(响应=>{
this.setState({someObject:response.data})
})
.catch(()=>{
errorPopup(“获取已接受和可用的作业”);
});
}
render(){
返回(
);
}
}
奇怪的是,当我调试和使用控制台时,我可以看到一个对象
\u errorPopup2


如何调用
errorPopup()
而不更改我采用的UTIL的设计模式?

模块路径似乎不正确,另一方面,请尝试打印控制台errorPopup并检查其中的内容。@jayant直到我再次检查,如果您已确保路径正确,则路径似乎正确,尝试通过将toast调用替换为console.warn('problem',problem)等来简化设置,只需调用
errorPopup(“…”)
JobsList
Component中的
即可装载
,无需异步功能。谢谢。我试过了。我仍然会犯同样的错误。