Bug in breadcrumb.js for catch-all routes in react router

Forum rules
Please note that response time for technical support is within 3-5 business days.
Post Reply
yampan
Posts: 6
Joined: 09 Oct 2022, 16:26

01 Dec 2022, 16:50

Hi,

I encounter an error when I have a catch-all route in app.js

Code: Select all

<Routes>
	// some valid routes....
	<Route path="*" element={<ErrorPage />} />
 </Routes>
The app crashed because of this line in breadcrumb.js

Code: Select all

const label = props.meta.label; // TypeError: undefined is not an object (evaluating 'props.meta.label')
My temp workaround

Code: Select all

    const label = props?.meta?.label;
    return label 
        ? <>{location.pathname === '/' ? <span>Current Working</span> : <span>{label}</span>}</> 
        : <span>No page found</span>
Kindly update in the next version. Thanks!

p/s: diamond is a beautiful piece of work. Keep it up!

habubey
Posts: 89
Joined: 24 Aug 2022, 13:17

02 Dec 2022, 11:21

Hey there!
Thank you so much for your nice compliments. We will continue to improve.
About your problem we'll check and get back to you immediately.
Bugra Beyduz
PrimeReact Core Developer
Github profile: https://github.com/habubey

ulasturan
Posts: 9
Joined: 06 Sep 2022, 08:31

12 Dec 2022, 08:32

Hi yampan,
Your workaround is seems correct.

Code: Select all

import React from 'react';
import { useLocation } from 'react-router-dom';

const AppBreadcrumb = (props) => {
    const location = useLocation();
    const label = props.meta.label ? props.meta.label : 'No page found';
    return <>{location.pathname === '/' ? <span>Dashboard</span> : <span>{label}</span>}</>;
};

export default AppBreadcrumb;
You can try this code block below until the release,
Ulaş Turan
PrimeReact Developer
Github profile: https://github.com/ulasturann

Post Reply

Return to “Diamond - PrimeReact”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 14 guests