react-router-guards icon indicating copy to clipboard operation
react-router-guards copied to clipboard

Expose new `LoadingPageComponentType` and `ErrorPageComponentType` types

Open joshpensky opened this issue 3 years ago • 0 comments

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, removes Record<string, any> from RouteError type definition (this can only ever be a string or null)
  • Adds new LoadingPageComponentType and ErrorPageComponentType types to describe the type of React component expected (added to export)
  • Updates usage of PageComponent to use specific LoadingPageComponent or ErrorPageComponent types
  • Updates intermediate example with NotFound to use error prop
  • Removes unused stylelint reference

How to test

  1. Pull down the repository and install (npm i, npm run bootstrap, npm start)
  2. Visit the router config at /demos/intermediate/src/router/index.tsx
  3. Confirm there is no error when passing the NotFound component into error prop
  4. Visit the project http://localhost:3001
  5. Visit a Missingno Pokémon. Confirm small error message appears under body text like so:
Screen Shot 2021-09-13 at 1 41 20 PM

joshpensky avatar Sep 13 '21 17:09 joshpensky