mirror of
https://github.com/mue/mue.git
synced 2026-07-13 12:07:45 +02:00
fix(collection): Unnecessary re-render
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { memo } from 'react';
|
||||
import { MdOutlineArrowForward, MdOutlineOpenInNew } from 'react-icons/md';
|
||||
import { Button } from 'components/Elements';
|
||||
import variables from 'config/variables';
|
||||
@@ -44,4 +45,5 @@ const Collection = ({ collections, collectionFunction }) => {
|
||||
);
|
||||
};
|
||||
|
||||
export { Collection as default, Collection };
|
||||
const MemoizedCollection = memo(Collection);
|
||||
export { MemoizedCollection as default, MemoizedCollection as Collection };
|
||||
|
||||
@@ -31,6 +31,20 @@ const ItemPage = () => {
|
||||
const [shareModal, setShareModal] = useState(false);
|
||||
const { selectedItem } = useMarketData();
|
||||
|
||||
const locale = localStorage.getItem('language');
|
||||
const shortLocale = locale.includes('_') ? locale.split('_')[0] : locale;
|
||||
let languageNames = new Intl.DisplayNames([shortLocale], { type: 'language' });
|
||||
|
||||
let dateObj, formattedDate;
|
||||
if (selectedItem?.updated_at) {
|
||||
dateObj = new Date(selectedItem?.updated_at);
|
||||
formattedDate = new Intl.DateTimeFormat(shortLocale, {
|
||||
year: 'numeric',
|
||||
month: 'long',
|
||||
day: '2-digit',
|
||||
}).format(dateObj);
|
||||
}
|
||||
|
||||
const getName = (name) => {
|
||||
const nameMappings = {
|
||||
photos: 'photo_packs',
|
||||
@@ -63,17 +77,17 @@ const ItemPage = () => {
|
||||
|
||||
/*if (this.props.data.data.sideload === true) {
|
||||
return template(variables.getMessage('marketplace:product.sideload_warning'));
|
||||
}
|
||||
}*/
|
||||
|
||||
if (this.props.data.data.image_api === true) {
|
||||
if (selectedItem?.image_api === true) {
|
||||
return template(variables.getMessage('marketplace:product.third_party_api'));
|
||||
}
|
||||
|
||||
if (this.props.data.data.language !== undefined && this.props.data.data.language !== null) {
|
||||
if (shortLocale !== this.props.data.data.language) {
|
||||
if (selectedItem?.language !== undefined && selectedItem?.language !== null) {
|
||||
if (shortLocale !== selectedItem?.language) {
|
||||
return template(variables.getMessage('marketplace:product.not_in_language'));
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
@@ -259,20 +273,6 @@ const ItemPage = () => {
|
||||
);
|
||||
};
|
||||
|
||||
const locale = localStorage.getItem('language');
|
||||
const shortLocale = locale.includes('_') ? locale.split('_')[0] : locale;
|
||||
let languageNames = new Intl.DisplayNames([shortLocale], { type: 'language' });
|
||||
|
||||
let dateObj, formattedDate;
|
||||
if (selectedItem?.updated_at) {
|
||||
dateObj = new Date(selectedItem?.updated_at);
|
||||
formattedDate = new Intl.DateTimeFormat(shortLocale, {
|
||||
year: 'numeric',
|
||||
month: 'long',
|
||||
day: '2-digit',
|
||||
}).format(dateObj);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
document.querySelector('#modal').scrollTop = 0;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user