reach/tabs can't be used with react-router
See original GitHub issueš Bug report
Current Behavior
To be able to have all the browser native features (open in new tab, copy linkā¦) I want to use reach/tabs
with Link
from react-router
. So far Iām failing, and I donāt really know why š
Expected behavior
I want to have a tab system connected to the router.
Reproducible example
https://codesandbox.io/s/small-cdn-dr1lh?file=/src/App.tsx
Click on one link/tab =>
Suggested solution(s)
Additional context
Iām using react-router:4.3.1
, all the details are in the repro example š
Your environment
Software | Name(s) | Version |
---|---|---|
Reach Package | tabs | 0.10.5 |
React | 16.12.0 | |
Browser | chrome | latest |
Assistive tech | ||
Node | ||
npm/yarn | ||
Operating System |
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Handling Tabs Using Page URLs and React Router Doms
Learn how to maintain your active tab by using URL parameters and leveraging React Router Dom instead of using React state.
Read more >Tabs - Reach UI
Accessible tabs component for React. ... You can render any other elements you want inside of Tabs , but TabList should only render...
Read more >Should I use react-router for a tabs component? - Stack Overflow
Yes, this is a perfect job for React Router because it focuses on simplifying the URL redirection process for Single Page Apps. The...
Read more >Announcing Reach UI Tabs - React Training
The latest member of the Reach UI family is here! Tab interfaces are incredibly common on the web, and really easy to build...
Read more >React & Material UI #19: Tabs + Tabs with React Router
In this video we go over:- The Material UI Tabs and Tab component documentation and props- How the Tab Panel in Material ui...
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
@chaance I did play a bit with the repro codesanding, and indeed this is working! Just noticed than when you are playing with the keyboard navigation (left / right to change tab) the url and the focus state are not following.
Hi,
Here what i found after some investigation:
ownRef.current.focus()
without checking if the target is a host element with afocus
method (akaHTMLElement
)ref
property but the react-routerLink
component usesinnerRef
How can we improve this part?
focus
method?<Tab as={Link} asRef="innerRef" to="/three">
)In the mean time, (not tested) i guess you can wrap the
Link
into aCustomLink
to forward theref
prop to the react-routerinnerRef
property.I think i can provide a PR when weāll have chosen an option.