Notice: rename Warn -> Notice and add composability
The Notice component can now act as a general indicator component, exposing four types: "wait", "help", "warn", or "none". These types display different icons and make this a much more reusable element. We also render children passed to us, making this even more extendable. In future, we may wish to extract all message props altogether as children instead.
This commit is contained in:
@@ -6,7 +6,11 @@ import Toolbar from "../Toolbar/Toolbar";
|
||||
import IconGrid from "../IconGrid/IconGrid";
|
||||
import Footer from "../Footer/Footer";
|
||||
import ErrorBoundary from "../ErrorBoundary/ErrorBoundary";
|
||||
import Warn from "../Warn/Warn";
|
||||
import Notice from "../Notice/Notice";
|
||||
|
||||
const errorFallback = <Notice message="Search error" />;
|
||||
// const waitingFallback = <Notice type="wait" message="Loading..." />;
|
||||
const waitingFallback = <Notice type="none" message="" />;
|
||||
|
||||
const App: React.FC<any> = () => {
|
||||
return (
|
||||
@@ -14,8 +18,8 @@ const App: React.FC<any> = () => {
|
||||
<Header />
|
||||
<main>
|
||||
<Toolbar />
|
||||
<ErrorBoundary fallback={<Warn message="Search error"/>}>
|
||||
<Suspense fallback={<div>Loading...</div>}>
|
||||
<ErrorBoundary fallback={errorFallback}>
|
||||
<Suspense fallback={waitingFallback}>
|
||||
<IconGrid />
|
||||
</Suspense>
|
||||
</ErrorBoundary>
|
||||
|
||||
Reference in New Issue
Block a user