Skip to content

URL Routing Support (SPA) #2

Closed
Closed
@Archmonger

Description

@Archmonger

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions