What is the difference between mapStateToProps() and mapDispatchToProps()?
mapStateToProps() | mapDispatchToProps() |
---|---|
It is a function that is used to provide the stored data to the component. | It is a function that is used to provide the action creators with props to the component. |
All the results of mapStateToProps() should be the plain object that will later be merged into the component’s prop. | By mapDispatchToProps(), all the action creators are wrapped in the dispatcher call so that they may be called upon directly and will be merged into the component’s prop. |
It is used to connect the redux state to the props of the react component. | It is used to connect redux actions to the react props. |
BY Best Interview Question ON 31 May 2021