diff --git a/src/components/App.js b/src/components/App.js
index 163501d..ea39df3 100644
--- a/src/components/App.js
+++ b/src/components/App.js
@@ -1,4 +1,6 @@
import React, { Suspense, lazy } from "react";
+import ErrorBoundary from "./ErrorBoundary";
+import Fallback from "./Fallback";
const Counter = lazy(() => import("./Counter"));
const App = () => {
@@ -7,14 +9,16 @@ const App = () => {
{/* messing up on purpose */}
- {testMessage}
+ {testMessage}
- Loading...
}>
- {/* another mistake */}
-
-
-
-
+
+ Loading...}>
+ {/* another mistake */}
+
+
+
+
+
);
};
diff --git a/src/components/Fallback.js b/src/components/Fallback.js
new file mode 100644
index 0000000..2d07465
--- /dev/null
+++ b/src/components/Fallback.js
@@ -0,0 +1,19 @@
+import React from "react";
+import PropTypes from "prop-types";
+
+const Fallback = ({ message, criticalRenderPath }) => {
+ return (
+
+ {criticalRenderPath && (
+
{message || "Something went wrong, please retry"}
+ )}
+
+ );
+};
+
+Fallback.propTypes = {
+ message: PropTypes.string,
+ criticalRenderPath: PropTypes.bool,
+};
+
+export default Fallback;
diff --git a/src/styles/global.scss b/src/styles/global.scss
index d353c5b..2185b9d 100644
--- a/src/styles/global.scss
+++ b/src/styles/global.scss
@@ -10,3 +10,6 @@ button {
margin-right: 16px;
}
+.red {
+ color: red;
+}