Код: Выделить всё
useAppStoreКод: Выделить всё
const MessageList: React.FC = ({ popupId }) => {
const {
popups,
isLoading,
liveResponse: response,
liveAttachments,
updateVisibleMessages,
} = useAppStore();
< /code>
[list]
[*] popupsКод: Выделить всё
const MessageList: React.FC = ({ popupId }) => {
const themeStyle = useAppStore((state) => state.popups.find((p) => p.id === popupId)?.themeStyle);
const currentNodeId = useAppStore((state) => state.popups.find((p) => p.id === popupId)?.currentNodeId);
const messagesMap = useAppStore((state) => state.popups.find((p) => p.id === popupId)?.messagesMap);
const lastUserMessage = useAppStore((state) => state.popups.find((p) => p.id === popupId)?.lastUserMessage);
const cachedVisibleMessages = useAppStore((state) => state.popups.find((p) => p.id === popupId)?.cachedVisibleMessages);
Код: Выделить всё
const { position, title } = useAppStore((state) => ({
position: state.popups[popupId]?.position,
title: state.popups[popupId]?.title,
}));
Вопрос: Если мои предположения правильны, как сделать код в 2. Выглядеть более компактно и не повторно (сухое)? Кэширует его в магазине единственным решением?
Подробнее здесь: https://stackoverflow.com/questions/796 ... -component
Мобильная версия