Actually I'm setting up a new project, got confused about choosing a flow:
- useState + useReducer + useContext
or
- Redux
The project is advanced and medium sized, it may leads to large app in near future or may not be.
If I go with option 1 (useState + useReducer + useContext) :
a. There is no middleware for useReducer (yet). Since it's not one global state container, it's difficult to apply such middleware globally. b. There is no native feature (yet) which combines all reducers to one ultimate reducer.
If I go with option 2, I can use the features which option 1 fails to provide.
I came across, that we can implement we can combine multiple reducers manually in option 1:
import userReducer from './reducers/user';
import basketReducer from './reducers/basket';
const mainReducer = ({ user, basket }, action) => ({
user: userReducer(user, action),
basket: basketReducer(basket, action)
});
and can implement middleware too
import userReducer from './reducers/user';
import basketReducer from './reducers/basket';
const mainReducer = ({ user, basket }, action) => {
// middleware goes here, i.e calling analytics service, etc.
return {
user: userReducer(user, action),
basket: basketReducer(basket, action)
};
});
Actually I am freezing here to choose which way is optimal to go with ?
If I'm go with Redux, I have to implement Redux, axios, saga, immutable js or other third part libs. I'll be using powerful features of Redux and also I should learn all the concepts first for Redux. Since I know Context + hooks.
Is react officials have any plans to bring those missed ingredients from Redux to hooks + context ?