uprighted-learners / g3-react-chat

react-chat-aidrian created by GitHub Classroom
0 stars 1 forks source link

32 auth component - login #39

Closed aidanho1188 closed 8 months ago

aidanho1188 commented 8 months ago

Successfully handle user login but fail to navigate to the next page. We need to pass the userId to the next page somehow. From what I read, we can use dispatch and history.push("/", userId) to transfer userId to the next page, not sure how to do it tho. We can either put a hold on this problem and merge the current code back into 32-auth-component, or keep this branch until it complete and then merge it.

aidanho1188 commented 8 months ago

Apparently, version 6.0 of react-router-dom changed a lot of methods. In this case we need to use "useNaviate" instead of "useHistory". I also learn about localStorage which is a property of the window interface (part of DOM). So we can use this instead of doing props drilling to access user information.

https://reactrouter.com/en/main/upgrading/v5#use-usenavigate-instead-of-usehistory