Problems in react router

I used Link element from react-router-Dom but still my page refreshes while going into the other page. I also used LinkContainer but it gives unexpected App error.
This is my repo:

Hi @Yusuf, I see that you have resolved the problem by adding an _redirects file in your public folder with the content /* /index.html 200

The above should resolve your problem however kindly confirm if it’s been resolved or not.
Also if there is anything else you want help with, let us know.

Thanks.

I used target attribute with blank value in my link to the other page, now I’ve removed it and it goes directly to the other page but removes everything I put in my form.

Hi @Yusuf, kindly explain further what your new problem is regarding what happens when you move from a page to another page and then everything gets cleared in your form.
Which page is your form located and which pages do you transition from to cause the form to get cleared.

Thanks.

my main page which is Home.js in repo has the form but when I write anything in name or email section and don’t submit it gets cleared automatically when I go to the other page through navbar “available cars”.

Hi @Yusuf, thanks for the clarification.
Since you are using React you need to keep the form data in state. There are 2 types of states which could be at component level or global level.
You can read more about Managing state in React at Managing State • React.

When you transition from one page to another the form component should be able to access the form state. Once you transition to a page without state the form data resets back to default.

Kindly watch the video below on how to use React State Managers at React State Management – Intermediate JavaScript Course - YouTube

Thanks.

1 Like

thank you for the help, much appreciated

1 Like

Hi @Yusuf, You are welcome, glad I was able to help.
Thanks.

Hi @Yusuf :wave:t6: thanks for confirming you got your solution. (; I’m glad our pilot could be of help.

1 Like