Current Situation
Currently, URL routes cannot be resolved.
Proposed Changes
Add support for URL routing.
Implementation Details
Create a React-Router equivalent.
Here an example on how this can be implemented
def route_component():
http.browser_router(
http.route("/"),
http.route("path_1/"),
http.route("path_2/")
)
And here's a reference video on explaining react-router.
Things to be implemented
BrowserRouter
- Top level location to signify "this part of the code contains routing"
Route
Link
- Clicking on the contents of this changes the browser URL, but does not perform a HTTP refresh on the page
- Basically just a
<a> tag with prevent_default pre-applied
- Should accept a kwarg of
regex: bool = False to allow for regex links
useHistory
useLocation
useParams
useMatch
Things that might not need to be implemented
Routes (formerly Switch)
- In ReactJS, this is used to allow
matching more than one potential path.
- Correction:
Routes is used to force the router to only match one path.
- In ReactPy, we might not need this if we add an
match_all kwarg within browser_router
NavLink
- It's just a link with extra styling. Doesn't really matter.
Redirect
- Doesn't need to exist if we just tell the user to use a regular HREF to do a HTTP page load.
MemoryRouter
- Debug utility that isn't that important.
StaticRouter
- Used for server side rendering, which we don't differentiate between.
Prompt
- Just a pop-up asking whether you really want to navigate away from the page
- This is useful but is way lower priority
Current Situation
Currently, URL routes cannot be resolved.
Proposed Changes
Add support for URL routing.
Implementation Details
Create a
React-Routerequivalent.Here an example on how this can be implemented
And here's a reference video on explaining react-router.
Things to be implemented
BrowserRouterRouteregex: bool = Falseto allow for regex routes?Link<a>tag withprevent_defaultpre-appliedregex: bool = Falseto allow for regex linksuseHistoryuseLocationuseParamsuseMatchThings that might not need to be implemented
Routes(formerlySwitch)matching more than one potential path.Routesis used to force the router to only match one path.match_allkwarg withinbrowser_routerNavLinkRedirectMemoryRouterStaticRouterPrompt