简体   繁体   中英

What is the reason behind implementing redux store as a function, not a class?

Last day I was trying to write a wrapper around Redux store but I had to copy and paste some code in order to create the same API. With react I could easily extend my class from React.Component so I was thinking why developers of Redux have not implemented their store like this? here is copy of the store code:

https://github.com/reactjs/redux/blob/master/src/createStore.js

Because you can use enhancer s instead, which allow you to compose multiple functions with the store in the particular order you want. Using inheritance would require that all your third party enhancers inherit from each other in the order you need them to.

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