score:1

Accepted answer

the issue is likely that the moviepage component needs to react to the movieid route param updating.

given route:

<route name="movie" path="/movie/:movieid"  exact>
  <moviepage />
</route>

moviepage:

use an useeffect hook to handle any logic/data fetching/etc based on the movieid param updating.

const { movieid } = useparams();

react.useeffect(() => {
  // movieid on initial render or subsequent render when updated
  // logic to use movieid and resynchronize any data.
}, [movieid]);

if still using class components, then use the componentdidupdate lifecycle method. (assumes moviepage wrapped in withrouter hoc to receive route props, specifically the match prop)

componentdidupdate(prevprops, prevstate) {
  if (prevprops.match.params.movieid !== this.props.match.params.movieid) {
    // logic to use movieid and resynchronize any data.
  }
}

Related Query

More Query from same tag