Router
Reviewing a React router component implemented with Mosaic for Mosaic
Last updated
Was this helpful?
Reviewing a React router component implemented with Mosaic for Mosaic
Last updated
Was this helpful?
In any frontend or backend application, the router is a place which is one of the most important ones to make plugin-friendly, when using Mosaic. Any amount of routes can be added to it, if it is designed correctly.
This article will demonstrate a router design from project, which is written completely in Mosaic.
Let's see the router itself! It is also available on . This is exactly the form of the router at the moment of writing this article.
It is clearly visible that the router does not actually render any routes! It just provides several convenient points for modification with Mosaic : _beforeSwitchRenderList
, _switchRenderList
and _afterSwitchRenderList
A router is pointless without routes, right? So let's add a route to the one defined above! We will use the for this purpose.
As you see, the plugin declaration file presented below modifies the of the class above, a member called _switchRenderList
of member-property
It implements a addCartPage
, which accepts the initial member - sorted render map _switchRenderList
declared above, adds an additional item to that map and returns the modified value to the application.