React ErrorBoundary Not Catching Errors – Red Screen with CRA Error Overlay

i’m working on a React application where I’ve implemented an ErrorBoundary component to catch and handle errors in my application. However, when I deliberately introduce an error in one of my components, I still get the Create React App (CRA) red error overlay instead of my custom error boundary’s fallback UI.
Here is my ErrorBoundary component:

import React from "react";
import PropTypes from "prop-types";
import { Navigate } from "react-router";

class ErrorBoundary extends React.Component {
  constructor(props) {
  super(props);
  this.state = { hasError: false, shouldGoBack: false, renderingError: null };
}

static getDerivedStateFromError(error) {
   return { hasError: true, renderingError: error };
}

 componentDidCatch(error, info) {
   // Prevent the error from propagating to the default CRA error overlay
   console.error("Error in component:", error);
   console.error("Error info:", info);
}

goBack = () => {
  this.setState({ shouldGoBack: true });
};

render() {
  const { hasError, shouldGoBack, renderingError } = this.state;
  const { children } = this.props;
  if (shouldGoBack) {
    return <Navigate to="/dashboard" />;
  }

if (hasError) {
  return (
    <div className="w-screen h-screen bg-[radial-gradient(ellipse_at_center,_var(-- 
      tw-gradient-stops))] from-steel-blue via-deep-navy to-eclipse-blue">
      <h1>Something went wrong</h1>
      <p>{renderingError && renderingError.toString()}</p>
      <button type="button" onClick={this.goBack}>
        Go back
      </button>
    </div>
  );
}

  return children;
 }
}

 ErrorBoundary.propTypes = {
     children: PropTypes.node.isRequired,
 };

  export default ErrorBoundary;

I wrapped my Outlet component with the ErrorBoundary in the Layout component:

import React from "react";
import { Outlet } from "react-router-dom";
import LeftSideBar from "../coreUI/LeftSideBar";
import Navbar from "../coreUI/Navbar";
import ErrorBoundary from "../components/ErrorBoundary";

function Layout() {
  return (
    <div className="min-h-screen bg-[radial-gradient(ellipse_at_center,_var(--tw- 
     gradient-stops))] from-steel-blue via-deep-navy to-eclipse-blue">
      <div className="flex">
        <LeftSideBar />
          <div className="flex flex-col flex-1">
          <Navbar />
      <div className="flex flex-col items-center mb-10 mt-10">
        <div>
          {/* <img src={DshareLogo} alt="DshareLogo" className="w-40" /> */}
        </div>
      </div>

      <div className="flex justify-center items-center h-full">
        <ErrorBoundary>
          <Outlet />
        </ErrorBoundary>
      </div>
    </div>
  </div>
</div>
  );
}

export default Layout;

In my Dashboard component, I introduced an intentional error to test the ErrorBoundary:

     import React from "react";
     
    
function Dashboard() {
  return <div>{undefined.name}</div>; // Intentional error
   
return (
 <div className="flex flex-col items-center justify-center ">
    <ListTable />
   </div>
  );
}

   export default Dashboard;

Despite setting FAST_REFRESH=false in my .env file and restarting the development server, I still see the red screen error overlay from CRA:
Uncaught runtime errors:
×
ERROR
Cannot read properties of undefined (reading ‘name’)
TypeError: Cannot read properties of undefined (reading ‘name’)
at Dashboard (http://localhost:3000/static/js/bundle.js:11701:25)
at renderWithHooks (http://localhost:3000/static/js/bundle.js:62221:22)
at mountIndeterminateComponent (http://localhost:3000/static/js/bundle.js:65507:17)
at beginWork (http://localhost:3000/static/js/bundle.js:66803:20)
at HTMLUnknownElement.callCallback (http://localhost:3000/static/js/bundle.js:51813:18)
at Object.invokeGuardedCallbackDev (http://localhost:3000/static/js/bundle.js:51857:20)
at invokeGuardedCallback (http://localhost:3000/static/js/bundle.js:51914:35)
at beginWork$1 (http://localhost:3000/static/js/bundle.js:71788:11)
at performUnitOfWork (http://localhost:3000/static/js/bundle.js:71035:16)
at workLoopSync (http://localhost:3000/static/js/bundle.js:70958:9)

Why is the CRA error overlay still showing despite disabling FAST_REFRESH?

How can I ensure that my custom ErrorBoundary catches errors and displays the fallback UI in development and production?
Any help would be greatly appreciated!

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật