Fix rerenders on model select

This commit is contained in:
blessedcoolant 2022-11-22 18:25:22 +13:00
parent dc5d696ed2
commit 3ea732365c

View File

@ -7,23 +7,31 @@ import _ from 'lodash';
import { ChangeEvent } from 'react'; import { ChangeEvent } from 'react';
import { systemSelector } from '../store/systemSelectors'; import { systemSelector } from '../store/systemSelectors';
const selector = createSelector([systemSelector], (system) => { const selector = createSelector(
const { isProcessing, model_list } = system; [systemSelector],
const models = _.map(model_list, (model, key) => key); (system) => {
const activeModel = _.reduce( const { isProcessing, model_list } = system;
model_list, const models = _.map(model_list, (model, key) => key);
(acc, model, key) => { const activeModel = _.reduce(
if (model.status === 'active') { model_list,
acc = key; (acc, model, key) => {
} if (model.status === 'active') {
acc = key;
}
return acc; return acc;
},
''
);
return { models, activeModel, isProcessing };
},
{
memoizeOptions: {
resultEqualityCheck: _.isEqual,
}, },
'' }
); );
return { models, activeModel, isProcessing };
});
const ModelSelect = () => { const ModelSelect = () => {
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();