Skip to content
Advertisement

How can I pass parameters to route with navigate function in react?

Is there a way to pass some parameters to a route with the navigate function is react? I found the below approach, but it doesn’t work since the route parameter in the second file is undefined.

JavaScript
JavaScript

Advertisement

Answer

You can pass the data this way

JavaScript

And your SingleTopic will become

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement