I save the data in create store as:
>First, I have a reducer that contains all the data.
export const makeRootReducer = (asyncReducers) => {
return combineReducers({
location: locationReducer,
req:allReducers,
user: home,
...asyncReducers
})
}
>In Create store, I passed this reducer.
< pre>const store = createStore(
makeRootReducer(),
initialState,
composeEnhancers(
applyMiddleware(…middleware),
… enhancers
)
)
Please suggest me how to avoid memory leaks?
You don’t have to store all your data in the store, and you shouldn’t.
If your data is large, you have to split it and load it by scheduling some operations, These operations will use some third-party modules (such as redux-thunk or saga) to handle asynchronous calls.Example: (http request or stream socket).
Think about it like you just need to be in the store It only stores the data that the user needs to navigate and what he wants to see.
I hope to help you
We know that the provider will store All the data in the store is provided to our application, but I want to know the memory because we are saving all the data of our application when creating the store. Now, if my application has multiple pages that contain a lot of data, then All data will be stored, and there is a risk of memory leak in this case. So how do we dynamically clear and store the data in react-redux to overcome this memory leak.
The data saved in create store is:
>First, I have a reducer that contains all the data.
export const makeRootReducer = (asyncReducers) => {
return combineReducers({
location: locationReducer,
req:allReducers,
user: home,
...asyncReducers
})
)
>In Create store, I passed this reducer.
const store = createStore(
makeRootReducer(),
initialState,
composeEnhancers(
applyMiddleware(...middleware),
...enhancers
)
)
Please build How can I avoid memory leaks?
The store is only used to save the data or certain user input that you will present and present to the user.
You do not have to store all the data in the store , It shouldn’t be done.
If your data is large, you must split it and load it by scheduling some operations, which will use some third-party modules (such as redux- thunk or saga) to handle asynchronous callsExample: (http request or stream socket).
Think about it like you only need to store in the store the data that the user needs to navigate and what he wants to see That’s it.
I hope I can help you