Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

201
Views
React js createSelector reselect does not work. Issue connected with quality of renders

React js reselect does not work, while I use him in the slice. I have created big project smth like social media app, however when I wanted to check the quality of renders, I saw that the whole page is rendering for 6 or 7 times.

here is the image

import {createSlice} from '@reduxjs/toolkit';
import {createSelector} from "reselect";

export const optimizedEventsSlice = createSlice({
 name: 'optimizedEvents',
        initialState: {
           optimizedEvents: {
           next: null,
           previous: null,
           results: []
        }
},
 reducers: {
    initOptimizedEvents: (state, action) => {
        state.optimizedEvents = action.payload;
        },
   },
 });

 export const {
   initOptimizedEvents
 } = optimizedEventsSlice.actions;

 // export const getOptimizedEvents = (state) => state.optimizedEvents;

 export const getOptimizedEvents = createSelector(
   (state) => state.optimizedEvents,
   (optimizedEvents)=> optimizedEvents
 );

 export default optimizedEventsSlice.reducer;
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The selector you have written isn't doing anything useful at all. Any selector that finishes with x => x as its "output selector" isn't actually memoizing anything. Additionally, by returning the entire slice state, you are telling the UI layer that it should re-render any time state.optimizedEvents is updated in any way.

I'd recommend reading the Redux docs page on Deriving Data with Selectors to better understand how Reselect works and how to use it correctly.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!