RouterComponent
RouterComponent
is a class provided by Rasengan.js used to create Routers in your application.
Learn what Routers
are here.
Usage
app.router.tsx
import { RouterComponent, defineRouter } from "rasengan";
class AppRouter extends RouterComponent {};
export default defineRouter({
imports: [], // Import others routers
layout: null, // Set a layout
pages: [] // Import pages
})(AppRouter)
Properties
Here is the list of all the properties of RouterComponent
class.
Properties | Type | Description |
---|---|---|
routers | RouterComponent[] | An array of other Router classes to be imported. |
layout | LayoutComponent | The layout component to be used. |
pages | PageComponent[] | An array of page components to be used. |
notFoundComponent | React.FC | The 404 page component to be used. |
loaderComponent | React.FC | The loader component to be used. |
Rather than setting these values manually, the defineRouter
does it for us and create a new instance of RouterComponent
class and return it.