From e562d10d6e402639e24509ca6eb5f15ee2e4ef93 Mon Sep 17 00:00:00 2001 From: Mrugesh Mohapatra <1884376+raisedadead@users.noreply.github.com> Date: Sat, 27 May 2023 04:35:32 +0530 Subject: [PATCH] revert: show the default 404 page only when profile fails (#50528) --- .../show-profile-or-four-oh-four.tsx | 39 ++++--------------- 1 file changed, 8 insertions(+), 31 deletions(-) diff --git a/client/src/client-only-routes/show-profile-or-four-oh-four.tsx b/client/src/client-only-routes/show-profile-or-four-oh-four.tsx index 92249c34a2d..03f40621e16 100644 --- a/client/src/client-only-routes/show-profile-or-four-oh-four.tsx +++ b/client/src/client-only-routes/show-profile-or-four-oh-four.tsx @@ -4,6 +4,7 @@ import { connect } from 'react-redux'; import { isBrowser } from '../../utils/index'; import Loader from '../components/helpers/loader'; +import Profile from '../components/profile/profile'; import { fetchProfileForUser } from '../redux/actions'; import { usernameSelector, @@ -12,7 +13,6 @@ import { } from '../redux/selectors'; import { User } from '../redux/prop-types'; -const Profile = lazy(() => import('../components/profile/profile')); const FourOhFour = lazy(() => import('../components/FourOhFour')); interface ShowProfileOrFourOhFourProps { @@ -56,32 +56,6 @@ const mapDispatchToProps: { fetchProfileForUser }; -type ErrorBoundaryProps = { - fallback: React.ReactNode; -}; - -class ErrorBoundary extends React.Component< - ErrorBoundaryProps, - { hasError: boolean } -> { - constructor(props: ErrorBoundaryProps) { - super(props); - this.state = { hasError: false }; - } - - static getDerivedStateFromError() { - return { hasError: true }; - } - - render() { - if (this.state.hasError) { - return this.props.fallback; - } - - return this.props.children; - } -} - function ShowProfileOrFourOhFour({ requestedUser, maybeUser, @@ -101,11 +75,14 @@ function ShowProfileOrFourOhFour({ if (!isBrowser()) { return null; } - return ( + + return isEmpty(requestedUser) ? ( }> - }> - - + + + ) : ( + }> + ); }