Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

The code of the component is unreachable although is getting the dynamic route param

Hi people 🙂 I am doing a project with React + JS and I have installed wouter and I am trying to make my app working with a dynamic params in the route. That means: if I go to "/gif/panda" that it will render the gifs of pandas. However, although I have been several hours researching, I dont know what happens. As you can see in console, the "/gif/:keyword/", I mean, the keyword is received by the component List of Gifs, as it returns the phrase "Hola Panda". Panda was the keyword. But I dont know why the return code of the component is unreacheable and, therefore, the app crashes. Any idea? Thanks.

enter image description here
enter image description here
enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You must put JSX code into brackets on return statement.(in ListofGifs component)
Since there is no brackets your function returns nothing. If you look carefully you can see that the code after return statement is pale which means it just doesn’t work. I added image below. I hope it solves problem.

add brackets

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading