Iman  Mohamadi
Iman Mohamadi

Reputation: 6829

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

Upvotes: 1

Views: 88

Answers (1)

Jessidhia
Jessidhia

Reputation: 534

Because you can use enhancers 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.

Upvotes: 2

Related Questions