import React, { useState, useEffect } from 'react'; import { Redirect, Route, Switch, useHistory, useRouteMatch, match as MatchType, Link as RouterLink, useParams, useLocation } from 'react-router-dom'; import ContentAccessor, { Content } from '../accessor/contents'; import { LoadingCircle } from '../component/loading'; import { Link, Paper, makeStyles, Theme, Box, useTheme, Typography } from '@material-ui/core'; import {ArrowBack as ArrowBackIcon } from '@material-ui/icons'; import { MangaReader } from './reader/manga'; import { ContentInfo, Headline, NavItem, NavList } from '../component/mod'; export const makeContentInfoUrl = (id: number) => `/doc/${id}`; export const makeMangaReaderUrl = (id: number) => `/doc/${id}/reader`; type ContentState = { content: Content | undefined, notfound: boolean, } export const ContentAbout = (prop: { match: MatchType }) => { const match = useRouteMatch<{id:string}>("/doc/:id"); if (match == null) { throw new Error("unreachable"); } const id = Number.parseInt(match.params['id']); const [info, setInfo] = useState({ content: undefined, notfound:false }); const location = useLocation(); console.log("state : "+location.state); const menu_list = ( }> ); useEffect(() => { (async () => { console.log("mount content about"); if (!isNaN(id)) { const c = await ContentAccessor.findById(id); setInfo({ content: c, notfound: c === undefined }); } })() return ()=>{console.log("unmount content about")} }, []); if (isNaN(id)) { return ( Oops. Invalid ID ); } else if(info.notfound){ return ( Content has been removed. ) } else if (info.content === undefined) { return ( ); } else return (
404 Not Found invalid url : {prop.match.path}
); }