Home > other >  Why use connect() when we can use Provider, useDispatch(), useSelector() to access store, dispatch a
Why use connect() when we can use Provider, useDispatch(), useSelector() to access store, dispatch a

Time:02-23

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

CodePudding user response:

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.

CodePudding user response:

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