diff --git a/src/components/ItaliaTheme/View/Commons/VenuesSmall.jsx b/src/components/ItaliaTheme/View/Commons/VenuesSmall.jsx index 9a7ed300d..4dc0a4bef 100644 --- a/src/components/ItaliaTheme/View/Commons/VenuesSmall.jsx +++ b/src/components/ItaliaTheme/View/Commons/VenuesSmall.jsx @@ -25,26 +25,28 @@ const messages = defineMessages({ * @params {object} location: object. * @returns {string} Markup of the component. */ -const Location = ({ location, show_icon }) => { +const Location = ({ location, show_icon, retrieve_data }) => { const intl = useIntl(); const url = flattenToAppURL(location['@id']); const key = `luogo${url}`; + let location_fo = location; + if (retrieve_data) { + const locationContent = useSelector( + (state) => state.content.subrequests?.[key], + ); + const loaded = locationContent?.loading || locationContent?.loaded; + const dispatch = useDispatch(); - const locationContent = useSelector( - (state) => state.content.subrequests?.[key], - ); - const loaded = locationContent?.loading || locationContent?.loaded; - const dispatch = useDispatch(); - - useEffect(() => { - if (!loaded) { - dispatch(getContent(url, null, key)); - } - return () => dispatch(resetContent(key)); - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [url]); + useEffect(() => { + if (!loaded) { + dispatch(getContent(url, null, key)); + } + return () => dispatch(resetContent(key)); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [url]); - let location_fo = locationContent?.data; + location_fo = locationContent?.data; + } return location_fo ? (
@@ -86,11 +88,16 @@ const Location = ({ location, show_icon }) => { * @params {object} content: Content object. * @returns {string} Markup of the component. */ -const VenuesSmall = ({ venues, show_icon }) => { +const VenuesSmall = ({ venues, show_icon, retrieve_data = true }) => { return venues ? (
{venues.map((item, i) => ( - + ))}
) : null;