简体   繁体   中英

use state if i'm using redux

if I'm using redux and redux saga to manage state but a lot of times I wanna do API request for something and I need the result only at this component is it ok to just use state? or this considered a bad practice because the idea behind redux is that all the states should be in one place

In my opinion, it is fine to do it in certain situations. However, you need to be aware of a situation when the request is pending and the user already navigated to a different page of your app. When a request comes back it will try to do this.setState on unmounted component!

So I think is that you should trust your instincts on this one :)

You probably have already seen it, but I will share it anyway. You might not need redux.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM