Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose new LoadingPageComponentType and ErrorPageComponentType types #84

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

joshpensky
Copy link
Member

@joshpensky joshpensky commented Sep 13, 2021

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 joshpensky added the bug Something isn't working label Sep 13, 2021
@joshpensky joshpensky self-assigned this Sep 13, 2021
@joshpensky joshpensky linked an issue Sep 13, 2021 that may be closed by this pull request
package/src/types.ts Outdated Show resolved Hide resolved
@joshpensky joshpensky changed the title Expand PageComponent type for error prop Expose new LoadingPageComponentType and ErrorPageComponentType types Sep 14, 2021
@joshpensky joshpensky changed the base branch from main to develop September 14, 2021 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to use error object in error page component with TypeScript?
1 participant