I am new to redux. I am trying to make a user login.
I just want to understand the logic to send information through action.
I want a user enters username and password and will be logged in and his status will be marked online. Here is the flow:
UI -> ACTION -> MIDDLEWARE -> REDUCER
So, when a user clicks on login button, that action will be passed to reducer.
I have 3 options to implement this:
- User clicks on login button, a function will be called which will get the user id of the user (using map in store.getState) and that id will be passed to action which then will be sent to reducer.
action(userid) => reducer
- User clicks on login button, a function will be called and then username will be passed to the action. The reducer then fetches the userid and set the status of the user id.
action(username) => reducer
- Use a middleware to fetch the userid and send that to reducer
action(username) => middleware => reducer
How should I apply log in logic to my app.