const HousesList = (props) => {
const { items } = props;
const [sorting, setSotring] = useState(/* состояние сортировки */);
const sortedItems = useMemo(
() => items.slice().sort(/* логика сортировки */),
[items, sorting],
);
/* дальше работаете с sortedItems */
};
собрать с его разных частей, объединить, вычислить и тп и тд.
Я слегка запутался что может, а что не может делать глупый, умный компонент
// запрашиваете дома при маунте компонента.
useEffect(() => {
dispatch(getHouses());
}, [dispatch]);
// запрашиваете историю при изменении houses.
useEffect(() => {
dispatch(getHousesHistory(houses));
}, [dispatch, houses]);
redux-saga
.
все производить уже "на месте".
Home
при любом изменении стора будет ререндерить всех детей. Если вынести логику из Home
будет ререндерится только компонент, который использует конкретный кусок стора.actions.js
на отдельные файлы; api.js
;thunks.js
(если у вас redux-thunk, по-хорошему асинхронные экшны должны через него проходить);obj
может быть Нечто
, у которого прототип — Нечто2
, у которого прототип уже Object
. Цикл идёт до первого прототипа в цепочке.
A comparison for equality with Object.prototype only works for objects that actually inherit from Object.prototype. This is not always the case for plain objects though, which might come from another realm - like an iframe - and inherit from the other realm's Object.prototype. To detect these, the code basically first searches for an Object.prototype-like (i.e. inheriting from null) object in the prototype chain of the argument, and then checks whether the argument directly inherits from that.