[Typescript] Breadcrumbs `as` parameter does not work with Reach Router as documented
See original GitHub issueDescribe the bug
Typescript claims a type error when attempting to use Link
from @reach/router
in the BreadcrumbLink
as
parameter as documented here
This may also affect other components which use Link
Error:
Type 'typeof Link' is not assignable to type '"symbol" | "object" | "a" | "abbr" | "address" | "area" | "article" | "aside" | "audio" | "b" | "base" | "bdi" | "bdo" | "big" | "blockquote" | "body" | "br" | "button" | "canvas" | ... 157 more ... | undefined'.
Type 'typeof Link' is not assignable to type 'ComponentClass<any, any> & string'.
Type 'typeof Link' is not assignable to type 'string'.
Expected Behavior The types should match to allow use as documented and as allowed in JS.
To Reproduce
- Use this template:
yarn create react-app bug-demo --typescript
Install chakra-ui as documented Use this component:
import React from 'react'
import {Breadcrumb, BreadcrumbItem, BreadcrumbLink} from '@chakra-ui/core'
import {Link} from '@reach/router'
export const Bug = () => (
<Breadcrumb>
<BreadcrumbItem>
<BreadcrumbLink as={Link} to="/">Test</BreadcrumbLink>
</BreadcrumbItem>
<Breadcrumb>
)
- List the steps to reproduce the behavior:
yarn start
Suggested solution(s)
Change the typing on as
to be more inclusive. Perhaps ReactNode
instead of ElementType
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Reach Router
This is useful for Routers rendered as asides, headers, breadcrumbs etc. but not the main content.
Read more >Dynamic breadcrumbs using react router - Stack Overflow
We have to recursively flatten navigation and render it a flat array: const routes = flattenRoutes(navigation); return (<Router> {routes. map(( ...
Read more >use-react-router-breadcrumbs - npm
Add breadcrumbs to your existing route object. This is a great way to keep all routing config paths in a single place! If...
Read more >Building Dynamic Breadcrumbs in NextJS - DEV Community
Breadcrumbs are a website navigation tool that allows users to see their current page's "stack" of how it is nested under any parent...
Read more >Automatically generating a breadcrumb with React Router
Providing the user a path of going back in a UI is a must, so adding a navigational element that shows the route...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @DavidJFelix,
I’m going to close this considering it’s a duplicate in the #205 issue. We’ve resolved this permanently in the TypeScript branch. It should be released by next month.
Thanks
unstale. this still exists with a number of link-based components when using reach