Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between useSelector and useAppSelector?

I came across useAppSelector while using redux with RTK query. So what will be the difference between useSelector and useAppSelector gonna be or both works in the same way?

like image 290
Anshik gupta Avatar asked Apr 22 '26 05:04

Anshik gupta


1 Answers

On a runtime level, they are 100% equal. The difference is that one is untyped so the state variable is unknown and needs to be manually typed by you on every single call of useSelector - and you can pass in everything wrong there without causing an error.

useAppSelector on the other hand gets declared with your RootState in one place and after that it's typesafe, ready to be used everywhere in your application.

like image 167
phry Avatar answered Apr 24 '26 18:04

phry



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!