diff --git a/hocs/withFallback.js b/hocs/withFallback.js new file mode 100644 index 0000000..4c67c66 --- /dev/null +++ b/hocs/withFallback.js @@ -0,0 +1,33 @@ +import { useRouter } from "next/router"; +import styled from "styled-components"; +import LoadingAnimation from "../components/LoadingAnimation"; + +const Center = styled.div` + display: flex; + align-items: center; + justify-content: center; + + height: 100vh; +`; + +/** + * HOC for statically rendered page with fallback activated + * @param {} WrappedComponent + */ +export default function withFallback(WrappedComponent) { + const withFallbackWrapper = (props) => { + const router = useRouter(); + + if (router.isFallback) { + return ( +
+ +
+ ); + } + + return ; + }; + + return withFallbackWrapper; +}