简体   繁体   中英

Can I access the redux dispatch directly from inside an action creator by requiring it?

在redux动作创建者内部,是否合理地简单地要求redux商店使用require('path/to/store')来访问getState()dispatch()因为它是单例的?

No, please don't do that - importing the store directly is an anti-pattern .

Use the redux-thunk middleware instead, as it's specifically intended for this use case.

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