-
Notifications
You must be signed in to change notification settings - Fork 5
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
RFC: static operator for defining groups of routes #1
Comments
Also, declarative api like this one, can probably more or less easily used with other UI-frameworks 🤔 |
I propose to name method like Ex.: on the readme.md we have an example: import { HomePage } from './routes'
const router = createHistoryRouter({ routes }); If method would have name Why
|
🤔 Maybe it could be just |
I don't like short names, because they are don't describe what really they are doing. I think it is better to name operators/methods as a verb. With |
I suggest to add an static operator (like @effector/reflect) to define groups of routes and their veiws
I think, that declarative static config it is better for a few reasons:
It may look something like that
(it is just an RFC of the API, with some of the cases, i think, api like that may cover)
Base api
Operator, which takes a list of routes and views and returns React component, which renders specific view based on which route can be matched
This operator must be called statically - not inside reactive context like React itself
Defaults
Once rendered, component must decide which route to render - but if there is no matched routes, something still may be rendered:
Also it may be not the render, but some action instead 🤔
Additional configuration
I think, that static definition allows to setup additional configuration for every route, something like that
Also, i think, route groups may have config themselves 🤔
Nested routes
I think, route groups can be nested in each other - this way it becomes easier to create subroutes
Since decision about which route to render still happens at react in runtime, nesting can be done this way too:
But since all configuration can be done via declarative config of
routes
, there is no need to do some tricky control flow in react and still support hardcore cases, like nested tabs inside other nested tabs and so on - runtime part just have to check, which of its routes list currently matches firstThe text was updated successfully, but these errors were encountered: