swsnu / swppfall2021

Learning Software Engineering By Building Web Services
28 stars 19 forks source link

Question about React Router in lab3 #42

Open lfoyh6591 opened 2 years ago

lfoyh6591 commented 2 years ago

What's the difference with Redirect and NavLink? I thought they have similar attribute which is to go to another link . Then why did we use Redirect on NewTodo.js, and NavLink on TodoList.js?

chang-jin commented 2 years ago

Redirect redirects a user to the destination instantly. However, NavLink makes a link to the destination. (like this NavLink) By putting NavLink, we can give user a choice to go to the page or not.

On NewTodo, we designed to go back to TodoList on submit button by force (without user's choice). On TodoList, we just made a link that user could select to go to NewTodo or just stay on the current page.