Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You can use hooks with redux now, so what’s the purpose of using connect instead of useDispatch or useSelector?


Two big reasons: Values passed via connect can be validated by proptypes, and by using connect you can mount your component without redux. That may make sense for building shared components that may be used with redux in one part of your app, but without redux in another part. There are a lot of smaller reasons to prefer connect, but those are the big ones to me. FWIW I use both approaches depending on needs.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: