404.jsx


Overview

404.jsx is a React functional component file that implements a user-friendly 404 error page for a web application. Its primary purpose is to inform users when they have navigated to a non-existent route or page within the application. The component leverages UI elements from the Ant Design (antd) library to present a standardized and visually appealing error message, along with a call-to-action button that redirects users back to the main business page.

This file plays a crucial role in enhancing user experience by providing clear feedback on navigation errors and guiding users back to a valid route, thereby maintaining smooth application flow and reducing user frustration.


Component Details

NoFoundPage Component

Description

NoFoundPage is a stateless functional React component that renders a 404 error message using the Result component from antd. It displays a concise error code and message, and includes a button to navigate users back to the home or business page.

Usage

This component should be used as a fallback route or error boundary in the routing configuration of the application, typically rendered when no matching route is found.

Implementation

const NoFoundPage = () => {
  return (
    <Result
      status="404"
      title="404"
      subTitle="Page not found, please enter a correct address."
      extra={
        <Button type="primary" onClick={() => history.push('/')}>
          Business
        </Button>
      }
    />
  );
};

Parameters

Return Value

Key Elements

Example Usage

import NoFoundPage from './404.jsx';

// In your routing setup
<Route path="*" component={NoFoundPage} />

When a user navigates to an undefined route, this component displays the 404 page and allows navigation back to the main page.


Implementation Details


Interaction with Other System Parts


Visual Diagram

componentDiagram
    direction LR
    component NoFoundPage {
        +Result(status="404", title="404", subTitle, extra)
        +Button(type="primary", onClick)
    }
    NoFoundPage --> Result : renders
    Result --> Button : contains
    Button --> history : onClick triggers push('/')

Summary

This simple yet effective component ensures that users encountering invalid URLs receive helpful feedback and an immediate way to return to the application's main area, improving overall usability and navigation robustness.