Closed
Description
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
- This is where the actual URL path goes
- React Router uses some weird system for variables within URLs
- Instead of that, we can possibly support regex paths
- I'm a bit biased and I think django's URL route matching looks visually cleaner than regex though
- Can possibly accept a kwarg of
regex: bool = False
to allow for regex routes?
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 withprevent_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
(formerlySwitch
)- 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.
- Correction:
- In ReactPy, we might not need this if we add an
match_all
kwarg withinbrowser_router
- In ReactJS, this is used to allow
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
Metadata
Metadata
Assignees
Labels
No labels