-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor the fix for two active pills
The previous fix used hooks inside loops which should not be done (see https://legacy.reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level). As a workaround I decided to refactor the fix. Now we gather all resolved paths for all the pills that are in the menu using `resolvePath` function and we pass those paths to each pill component. Inside the component we check if `useMatch` hook returns anything for the given pill and if yes then we check if is is because it has asterisk (`*`) in it's path. If yes, then we first have to check if the url match any of the other pills using our array of resolved paths. If not then we can safely assume that this pill can be active.
- Loading branch information
1 parent
4cefd91
commit e288ce4
Showing
2 changed files
with
35 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters