Loading

Quipoin Menu

Learn • Practice • Grow

react / React-Redux Hooks
interview

Q1. What are React-Redux hooks?
React-Redux provides hooks like useSelector and useDispatch to interact with the Redux store in functional components. They replace the connect HOC.

Q2. How do you use useSelector?
useSelector accepts a selector function that extracts data from the store. Example: const count = useSelector(state => state.counter.value). It subscribes to the store and re-renders when the selected value changes.

Q3. How do you use useDispatch?
useDispatch returns the dispatch function. You can call dispatch with an action. Example: const dispatch = useDispatch(); dispatch(increment()).

Q4. What is the difference between useSelector and mapStateToProps?
useSelector is a hook that can be used inside functional components, while mapStateToProps is used with connect. useSelector is simpler and more flexible, and it automatically subscribes to updates.

Q5. Can you use multiple useSelector calls?
Yes, you can call useSelector multiple times to get different parts of state. Each call will cause a re-render only when that specific slice changes.