diff --git a/src/App.js b/src/App.js
index bb289f2..c71878f 100644
--- a/src/App.js
+++ b/src/App.js
@@ -4,11 +4,20 @@ import Layout from './hoc/Layout/Layout';
import BurgerBuilder from './containers/BurgerBuilder/BurgerBuilder';
class App extends Component {
+ state = {
+ show: true
+ };
+
+ componentDidMount() {
+ setTimeout(() => {
+ this.setState({show: false});
+ }, 3000);
+ }
render() {
return (
-
+ {this.state.show ? : null }
);
diff --git a/src/hoc/withErrorHandler/withErrorHandler.js b/src/hoc/withErrorHandler/withErrorHandler.js
index c9178f0..f36774d 100644
--- a/src/hoc/withErrorHandler/withErrorHandler.js
+++ b/src/hoc/withErrorHandler/withErrorHandler.js
@@ -10,16 +10,22 @@ const withErrorHandler = (WrappedComponent, axios) => {
}
componentWillMount() { // This will happen before child component rendering
- axios.interceptors.request.use(req => {
+ this.reqInterceptor = axios.interceptors.request.use(req => {
this.setState({ error: null });
return req;
});
- axios.interceptors.response.use(res => res, error => {
+ this.resInterceptor = axios.interceptors.response.use(res => res, error => {
this.setState({ error: error });
});
}
+ componentWillUnmount() {
+ console.log('Will Unmount', this.reqInterceptor, this.resInterceptor);
+ axios.interceptors.request.eject(this.reqInterceptor);
+ axios.interceptors.response.eject(this.resInterceptor);
+ }
+
errorConfirmedHandler = () => {
this.setState({ error: null });
}