Answer the question
In order to leave comments, you need to log in
Did I put a spoke in my wheel by switching to reselect?
Hey! there is an application on react + redux.
store is organized as follows:
const store = {
dictionary: {
1: {
id: 1,
title: 'post 1',
...
},
5: {
id: 5,
title: 'post 5,
...
},
},
blog: [1, 5, ...], // id постов которые отображаются в блоге (берутся из dictionary)
informer: [1, ....] // id постов которые отображаются в информере (берутся из dictionary)
}
// В компоненте
const section = useSelector((state) => state.router.section); 'blog' или 'informer'
const dictionary = useSelector((state) => state.posts.dictionary);
const posts = useSelector((state) => state.dictionary[section]);
....
posts.map((post) => (<Post key={post.id} {...dictionary[post.id]} />);
// В компоненте
const posts = useSelector(selectPosts);
...
posts.map((post) => (<Post key={post.id} {...dictionary[post.id]} />);
// selectActiveLooksList.js
export const selectSection = (state) => state.router.section;
export const selectDictionary = (state) => state.posts.dictionary;
export const selectPosts = createSelector(
[selectSection, selectDictionary],
(section, dictionary) => dictionary[section]
);
Answer the question
In order to leave comments, you need to log in
In your situation, reselect is redundant - you don't need to memoize selector results. This is not a spoke in the wheels of course, but at the moment it is absolutely superfluous.
In your case, no calculations are made in the selector, and, accordingly, performance is not improved. You're just caching what's already in the dictionary. Hence there is a memory leak.
netbins-denver connection is like a grape-bicycle)
after it stopped working pkhp? Is it just this script that doesn't work? what os? what server is deployed?
Download denwer , very easy to set up!
run your file through denwer (or any other webserver)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question