mirror of
https://github.com/invoke-ai/InvokeAI.git
synced 2026-04-23 03:00:31 -04:00
perf(ui): optimize all selectors 1
I learned that the inline selector syntax recreates the selector function on every render: ```ts const val = useAppSelector((s) => s.slice.val) ``` Not good! Better is to create a selector outside the function and use it. Doing that for all selectors now, most of the way through now. Feels snappier.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import type { RootState } from 'app/store/store';
|
||||
import { createSelector } from '@reduxjs/toolkit';
|
||||
import { selectConfigSlice } from 'features/system/store/configSlice';
|
||||
|
||||
export const configSelector = (state: RootState) => state.config;
|
||||
export const selectAllowPrivateBoards = createSelector(selectConfigSlice, (config) => config.allowPrivateBoards);
|
||||
|
||||
Reference in New Issue
Block a user