我在./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'
});
}
然后我尝试在componentWillMount
的{{1}}方法中调用它,并说./src/components/JobList.js
。
Uncaught ReferenceError: errorPopup is not defined
奇怪的是,当我调试并使用控制台时,我可以看到一个对象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 />
);
}
}
。
如何在不更改我从here采用的utils的设计模式的情况下调用_errorPopup2
?