1.0.6 • Published 1 year ago

easy-router-react v1.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago
npm install easy-router-react

or

yarn add easy-router-react

Usage

remember react-router-dom is required!!

Step 1

index.js

import { BrowserRouter } from "react-router-dom";

ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
  <React.StrictMode>
    <BrowserRouter>
        <App />
    </BrowserRouter>
  </React.StrictMode>
Step 2

routes.jsx

const routes = {
  // pages
  "/": <Home /> /*__ http://localhost:3000 __*/,
  "/signin": <SignIn /> /*__ http://localhost:3000/signin __*/,

  // If sub pages
  "/profile": {
    element: <ProfileLayout /> /*__ http://localhost:3000/profile  __*/,
    sub_pages: {
      "/": <Profile /> /*__ http://localhost:3000/profile __*/,
      orders: <MyOrders /> /*__ http://localhost:3000/profile/orders  __*/,
      settings: <Settings /> /*__ http://localhost:3000/profile/settings  __*/,
    },
  },

  // Put NotFound Component Here
  "*": <div>404 Not Found</div>,
};

export default routes;

App.jsx

import EasyRouter from "easy-router-react";
import routes from "./routes";

export default function App() {
  return (
    <>
      <header>Header</header>
      <EasyRouter routes={routes} />
      <footer>Footer</footer>
    </>
  );
}
1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago