react-router-guards
react-router-guards copied to clipboard
Expose new `LoadingPageComponentType` and `ErrorPageComponentType` types
Description
This fixes an issue with the PageComponent
type not allowing for the error
prop, that's used for error page components
Related issues
Addresses #56
What this does
- Adds
RouteError
to export, removesRecord<string, any>
fromRouteError
type definition (this can only ever be a string or null) - Adds new
LoadingPageComponentType
andErrorPageComponentType
types to describe the type of React component expected (added to export) - Updates usage of
PageComponent
to use specificLoadingPageComponent
orErrorPageComponent
types - Updates intermediate example with
NotFound
to useerror
prop - Removes unused
stylelint
reference
How to test
- Pull down the repository and install (
npm i
,npm run bootstrap
,npm start
) - Visit the router config at
/demos/intermediate/src/router/index.tsx
- Confirm there is no error when passing the
NotFound
component intoerror
prop - Visit the project http://localhost:3001
- Visit a Missingno Pokémon. Confirm small error message appears under body text like so:
