This repository was archived by the owner on Mar 13, 2025. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
Implemented methods
disableSidebarForRoute(route)
andenableSidebarForRoute (route)
which can disable (remove) and enable back the sidebar for some route.For example
disableSidebarForRoute('/micro-frontends-react-route/no-sidebar/*')
removes sidebar for all the routes which start from/micro-frontends-react-route/no-sidebar/
and its subroutes. Internally it uses Reach Route Match Logic, see https://reach.tech/router/api/Match.Reasoning
I suggest disabling sidebar by routes rather than having general methods like
disableSidebar()
andenableSideabar()
. Because by using such methods it would be easy to get issues like:So we would have to always remember about this and either apps should always
re-enable
sidebar on unmout. Or apps that need the sidebar have to alwaysenable
sidebar on load. This is very easy to forget about this.When we disable sidebar by the route we don't have to re-enable it. As sidebar would be removed only for matching routes.
Demo