diff --git a/packages/volto/news/6464.bugfix b/packages/volto/news/6464.bugfix new file mode 100644 index 0000000000..86dea0dda8 --- /dev/null +++ b/packages/volto/news/6464.bugfix @@ -0,0 +1 @@ +Fixed LinkView logged-in page flashing on screen when not logged in. @JeffersonBledsoe diff --git a/packages/volto/src/components/theme/View/LinkView.jsx b/packages/volto/src/components/theme/View/LinkView.jsx index e2f8538612..542e5d05c2 100644 --- a/packages/volto/src/components/theme/View/LinkView.jsx +++ b/packages/volto/src/components/theme/View/LinkView.jsx @@ -1,27 +1,19 @@ -import { useEffect } from 'react'; -import PropTypes from 'prop-types'; -import { useHistory } from 'react-router-dom'; -import { isInternalURL, flattenToAppURL } from '@plone/volto/helpers'; -import { Container as SemanticContainer } from 'semantic-ui-react'; import { UniversalLink } from '@plone/volto/components'; -import { Redirect } from 'react-router-dom'; -import { FormattedMessage } from 'react-intl'; +import { flattenToAppURL, isInternalURL } from '@plone/volto/helpers'; import config from '@plone/volto/registry'; +import PropTypes from 'prop-types'; +import { FormattedMessage } from 'react-intl'; +import { Redirect } from 'react-router-dom'; +import { Container as SemanticContainer } from 'semantic-ui-react'; const LinkView = ({ token, content }) => { - const history = useHistory(); - useEffect(() => { - if (!token) { - const { remoteUrl } = content; - if (isInternalURL(remoteUrl)) { - history.replace(flattenToAppURL(remoteUrl)); - } else if (!__SERVER__) { - window.location.href = flattenToAppURL(remoteUrl); - } + if (!token && content.remoteUrl) { + // React router can handle all redirects except for client-side to an external URL. + if (isInternalURL(content.remoteUrl) || __SERVER__) { + return ; } - }, [content, history, token]); - if (__SERVER__ && !token && content.remoteUrl) { - return ; + window.location.href = content.remoteUrl; + return null; } const { title, description, remoteUrl } = content; const { openExternalLinkInNewTab } = config.settings;