-
Notifications
You must be signed in to change notification settings - Fork 684
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[doc]: Tapping into Routes #3110
Comments
Hi @aagasi. Thank you for your report. Please, add a comment to assign the issue:
|
@magento export issue to JIRA project PWA as Task |
✅ Jira issue (https://jira.corp.magento.com/browse/PWA-1664) is successfully created for this issue. |
Hi @aagasi , thanks for reporting this. We have just triaged it and assigned it to an upcoming epic expanding extensibility. Unfortunately we do not have an estimate on when this will be completed at this time. |
Would something like this suffice in - const routeList = venia.reactComponent(
+ venia.reactComponent(
'@magento/venia-ui/lib/components/Routes/routes.js',
- async ({ routes }, self) => addRoutes(self, await routes.promise([]))
+ async ({ routes }, self) => addRoutes(self, await routes.promise(require('../defaultRoutes.json')))
);
-
- // Add our own default routes!
- addRoutes(routeList, require('../defaultRoutes.json'));
} Happy to make a PR for this |
@evan-burrell this is also an issue for a project I'm working on, your fix seems to resolve the issue and makes the routes tappable again. |
Well I guess the routes is already tappable and tapping does work, but it gets loaded twice.
That one is not tapable and will always load the default routes and add them.
Also containing the default routes. So removing or changing routes will always keep the original due the the extra untappable addRoutes. |
Describe the request
In the same way we tap into the routes to "push" new routes we can also change the default routes defined in /packages/venia-ui/lib/defaultRoutes.json
Possible solutions
How would you word this addition or change?
Screenshots
As we can see in the following image, makeRoutesTarget() initializes the Routes component. As part of this initialization if we have a target interceptor that "pushes" new routes to the routes array they will be added. Therefore in the routeList variable we'll have all those custom routes. After this, addRoutes(routeList, require('../defaultRoutes.json')) method is called with 2 params. The 2nd params is an array of default routes pre-defined for pwa.
If we need to edit some of the default pre-defined routes we can do it in our custom interceptor by tapping into routes target and specifiying the "pattern" that we want to update (see following image):
In the prior example, the "/communications" route is being updated to redirect to 404 whenever someone tries to access it.
The text was updated successfully, but these errors were encountered: