useLocation somehow breaks this component
See original GitHub issueHello, and thank you for this component.
I am using this component inside a Tabpane (provided by Antd) and so far it works fine, but somehow, adding React-router-dom’s useLocation
hook throws an error when switching tabs.
- On enabling the tab containing the Splitter and useLocation the component displays fine
- Switching to any other tab however throws
Cannot create pairs - parent has undefined or zero size: undefined.
error
Simply remove useLocation from the component and it starts working perfectly again. I honestly haven’t the faintest idea why it behaves that way, I’ve been at it all morning and I’m all out of ideas atm. Any pointers would be most helpful.
Thank you.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
useLocation somehow breaks this component #2 - GitHub
I am using this component inside a Tabpane (provided by Antd) and so far it works fine, but somehow, adding React-router-dom's useLocation ......
Read more >how can i fix use location error in my react app? - Stack Overflow
Wrap your app in Routes component. ... TODO: This error is probably because they somehow have 2 versions of the // router loaded....
Read more >useLocation() may be used only in the context of a Router ...
The error "useLocation() may be used only in the context of a Router component" occurs when we try to use the useLocation hook...
Read more >useLocation and useNavigate State (Redirect to ... - YouTube
FREE React Course (download & bonus content) - https://calcur.tech/free-react-courseReact YouTube Playlist ...
Read more >Migrating from @reach/router v6.6.1 - React Router
@reach/router v1.3 and React Router v6 import { useParams, useLocation, ... Also, as a page grows, you naturally break it into multiple components...
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
I think the problem is that the parent’s size isn’t correctly calculated. I’m not exactly sure why it happens with
useLocation
though. I can say more once I see an example.The project I’m on currently is ridiculously bloated. But I’ll try to share a simplified example. Thank you.