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.

Not Scrolling to Dynamically Created Elements

See original GitHub issue

I’m trying to use scroller.scrollTo to target elements created in a .map function. Here’s my code

                        {questions.map((ele,i)=>
                          <Element name={"question-" + i}>
                            <Question key             = { "question-"+i            }
                                      question        = { ele                      } 
                                      qInd            = { i                        }
                                      backgroundColor = { ele.backgroundColor      }
                                      color           = { ele.color                }
                                      type            = { ele.type                 } 
                                      results         = { this.state.quiz.results  } 
                                      score           = { this.score               }
                                      id            = { "question-"+i            }/>
                        </Element>
                        )}

Any ideas how to fix this?

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
fisshycommented, Oct 17, 2019

@jhlabs Too bad we can’t scroll to element by ID already

Yes, you can.

var Scroll = require('react-scroll');
var scroller = Scroll.scroller;

scroller.scrollTo("myid",  { ...props });
0reactions
ackvfcommented, Oct 16, 2019

@jhlabs Too bad we can’t scroll to element by ID already

Read more comments on GitHub >

github_iconTop Results From Across the Web

why scrolling is disabled when i add new element in ...
1 Answer 1 · The element you're adding is position: absolute so it's not part of the element layout, so the element doesn't...
Read more >
Scroll Trigger and Timeline not working with dynamically ...
Can someone help me with getting the dynamic elements to load before the timeline? I don't want to move my gsap to the...
Read more >
Perfect scrollbar not visible when elements are dynamically ...
Hello I am trying to dynamically load some links from an array(JSON encoded values) as a list inside a div using Javascript.
Read more >
Programmatically scroll to a dynamically created div
Insecure Resource. The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https....
Read more >
Element size and scrolling
Setting scrollTop to 0 or a big value, such as 1e9 will make the element scroll to the very top/bottom respectively. Don't take...
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