Answer the question
In order to leave comments, you need to log in
How to re-render elements in return on link change?
I have Route:
I have links where I pass ID:
<Route path="/film/:film" component={Film} />
<Link to={`/film/${res.filmId}`} >{res.nameRu}</Link>
filmId
values in the variable change name
, however, I have an external script connected:
There is also this markup :<script src="..."></script>
<div id="block" data-id={`${name}`}></div>
name
<div id="block" data-id={`${name}`}></div>
Answer the question
In order to leave comments, you need to log in
Maybe it will help someone: We take out the
script in useEffect
and set the dependency to name
.
We wrap our block in another one div
and assign it key={film}
.
Solution author: Mikhail Osher
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question