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.

onSetActive, onSetInactive callbacks firing incorrectly or not at all

See original GitHub issue

If I omit containerId prop on Link component and let default document scroll container I get incorrectly highlighted navbar item (previous item is still highlighted).

If I pass id of the div that has scroll to Link then onSetActive, onSetInactive callbacks aren’t firing at all.

Also if I specify offset prop, scrolling position is correct but highlighted navitem is incorrect (onSetActive, onSetInactive callbacks).

I tried setting a breakpoint at i.e.

webpack:///node_modules/react-scroll/modules/mixins/scroll-link.js

line 264 _this2.props.onSetInactive && _this2.props.onSetInactive(to, element);

and it’s not pausing at all. I tried investigating stack trace when container is document and it does pause in debugger but I can just see handlers array gets invoked and before that mount is called, it’s not much informative, I expected some conditions and then to see which one from them isn’t fulfilled.

To summarize:

onSetActive, onSetInactive callbacks aren’t firing at all when containerId is passed, or firing incorrectly when containerId is omitted or offset prop is being used.

Is this a bug, and is there a workaround for this? Can you give me advice what’s the best way to debug this?

Also I noticed container: PropTypes.object, isn’t supported in types in "@types/react-scroll": "^1.8.2",:

https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react-scroll/modules/components/Link.d.ts

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
fisshycommented, Sep 14, 2021

@therealdrtroll Your problem is the .active css

.active {
  color: white;
  background-color: red;
  /*padding: 6px 5px;*/
  border-radius: 8px;
}

First you click the link, then it calculate the position of the element, but once active class hits a Link, then the actual element gets pushed a few pixels below the actual scroll position.

Add the padding to your links from start or remove the padding from .active

0reactions
fisshycommented, Sep 15, 2021

@therealdrtroll Glad I could help 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

react-scroll
Its instance type 'Element' is not a valid JSX element. ... the div that has scroll to Link then onSetActive , onSetInactive callbacks...
Read more >
Many nested scrolling callbacks are not fired/called?
1 Answer 1 ... ListView does not support nested scroll, since ListView does not implement NestedScrollingChild. So nested scrolling callbacks will ...
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