import { Button, Result } from 'antd'; import React from 'react'; import { history } from 'umi'; // FC = Functional Component 使用這個類型有個好處就是,提醒你必須返回一個ReactNode // 在函數式組件中,無法像在類組件中一樣使用state和生命鈎子函數,但React提供了HOOK const NoFoundPage: React.FC<{}> = () => ( <Result status={404} title="404" subTitle="Sorry, the page you visited does not exist." extra={ <Button type="primary" onClick={() => history.push('/')}> Back Home </Button> } /> ); export default NoFoundPage;
{ path: '*', component: '@/pages/404' },