D
D
Daniel Chistyakov2021-04-15 00:57:06
React
Daniel Chistyakov, 2021-04-15 00:57:06

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>

When the link ( ) changes, the filmIdvalues ​​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

1 answer(s)
D
Daniel Chistyakov, 2021-04-25
@danielchistyakov

Maybe it will help someone: We take out the
script in useEffectand set the dependency to name.
We wrap our block in another one divand assign it key={film}.
Solution author: Mikhail Osher

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question