defineRouter
defineRouter
is an utility function that allows you to define a router by attaching pages
to it and setting a layout
and other options.
Options
defineRouter
accepts an object with the following options:
Option | Type | Description | Optional |
---|---|---|---|
imports | RouterComponent[] | An array of other Router classes to be imported. | Yes |
layout | LayoutComponent | The layout component to be used. | Yes |
pages | PageComponent[] | An array of page components to be used. | No |
notFoundComponent | React.FC | The 404 page component to be used. | Yes |
loaderComponent | React.FC | The loader component to be used. | Yes |
Returned value
defineRouter
returns a function that accepts a Router
class and returns a new Router
instance object with the options defined.