preact-router
preact-router copied to clipboard
Sorting routes by rank
<Router> component now sorts routes by count of path segments or by path string length as a fallback.
Maybe it would helpful allow programmers to specify rank explicitly?
This can be done with new rank attribute for route component. Or with using key attribute as rank.
Or with preserving order of <Router> component children when counts of path segments are equal (stable sort).
Hey @gnaeus - the stable sort is a really good point, since currently there is nothing defining which route gets precedence when two routes have the same length rank. It seems like it'd be fairly easy to add an explicit rank at the same time as adding stable sort. For just the stability option, perhaps we could make use of the routes' indices within .children?