I am new to javascript and react. I have done lots of Googling with no solution. I am trying to hide a button component on one of three pages/routes where it currently displays but when I try to do it, it hides on all the pages/routes. Here is the code:
const routes = [
{
path: '/:bookId/details',
title: 'Book Details',
component: BookDetailsPage,
hideButton: true
},
{
path: '/:bookId',
title: 'Details',
component: BookPage,
exact: true,
hideButton: false
},
{
path: '/',
title: 'Book',
component: BookListPage,
hideButton: false
}
];
const Page = (): React.ReactElement => {
const isBookDetailsPage = routes[0].hideButton; //returns true
return (
<ContentMasterLayout
title="Book"
action={
<Box display="flex">
//this approach hides the button on all pages
{!isBookDetailsPage &&
<BookButton transactionId={match?.params.bookId} />}
</Box>
}
>
<LocalRouter routes={routes} />
</ContentMasterLayout>
);
};
Please any help would be appreciated. Thanks in advance