Why use connect() when we can use Provider, useDispatch(), useSelector() to access store, dispatch and other important things React-Redux?

Viewed 216

By using Provider, useSelector(), useDispatch(), etc we can access all the important things, then why do we get need to use connect() ?

2 Answers

connect is an older API from before React introduced hooks. If you are using only functional components with hooks, you don't need to use connect, but if you need to use Redux from a class-based component, you will.

You don't have to use both connect and useSelector. use one of them only. connect is an old way. useSelector is new and more easy.

Related