user8112228
user8112228

Reputation: 17

React search for an element from map function and scroll to that location

I am trying to search an element from a map function and scroll to the location of that element -

const time = "1235"

return <RightWrapper>
    
    {arr.map((transcript) => (
  <p
    dangerouslySetInnerHTML={createMarkup(transcript)}
    key={transcript.id}
    
  ></p> </RightWrapper>

Here I want to search for value time(which in this case is 12345) in transcript and scroll to that part when there is a match.

Upvotes: 0

Views: 1329

Answers (1)

Dazly Gonsalves
Dazly Gonsalves

Reputation: 201

I'm not sure if this if how you want it to work but I just tried out a solution that matches that exact value in the list and scrolls to that section of the page.

https://codesandbox.io/s/blue-microservice-yqnz3b?file=/src/App.js

Upvotes: 1

Related Questions