Merge pull request #51 from PabloSzx/loading_share_page

share page loading
This commit is contained in:
Mike Cao 2020-08-22 16:46:41 -07:00 committed by GitHub
commit 05dc77ca35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,6 +6,7 @@ import NotFound from 'pages/404';
import { get } from 'lib/web';
export default function SharePage() {
const [loading, setLoading] = useState(true);
const [websiteId, setWebsiteId] = useState();
const [notFound, setNotFound] = useState(false);
const router = useRouter();
@ -23,10 +24,16 @@ export default function SharePage() {
useEffect(() => {
if (id) {
loadData();
loadData().finally(() => {
setLoading(false);
});
} else {
setLoading(false);
}
}, [id]);
if (loading) return null;
if (!id || notFound) {
return <NotFound />;
}