Is it best practice to keep form state in redux store?

Viewed 982

I was learning react and redux and wanted to create form having several fields. So, since the form data is required for other components to work properly, I thought of keeping form state in redux store. But, what I assume is that since every time a user clicks a button in keyboard, new action is dispatched to store. The question is will it affect performance of my app? Again, is it ok to keep form state in redux store and when every time we click a button in keyboard, new action is dispatched to store? Wont't it hit performance?

2 Answers

Actually, when you use the redux store, you do not have to dispatch event in every DOM activity. For instance, let assume user in /home route, when the user redirects to /list route you call the useEffect() lifecycle method for dispatching an action. And this action brings a list from the database. But when the all list items listed, and want to select one of them for display it's a detail page, you don't have to dispatch an action again. You can pass the props to another component (like "DetailComponent"). And in that component, you can show the information without dispatch an action.

Related