question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

useLocation somehow breaks this component

See original GitHub issue

Hello, 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:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
mlejvacommented, Mar 10, 2021

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.

1reaction
Unforgiven-wandacommented, Mar 10, 2021

The project I’m on currently is ridiculously bloated. But I’ll try to share a simplified example. Thank you.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found