Skip to content

Fix link usages #21

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

Merged
merged 2 commits into from
Jul 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 26 additions & 10 deletions docs/src/usage.md
Original file line number Diff line number Diff line change
@@ -92,16 +92,21 @@ This will allow ReactPy to handle the transition between routes more quickly by
the cost of a full page load.

```python
from reactpy import component, html, run
from reactpy_router import link, route, simple, use_location
from reactpy import component, html, run, use_location
from reactpy_router import link, route, simple

@component
def root():
location = use_location()
use_location()
return simple.router(
route("/", html.h1("Home Page 🏠")),
route(
"/",
html.div(
html.h1("Home Page 🏠"),
link(html.button("About"), to="/about"),
),
),
route("/about", html.h1("About Page 📖")),
link("/about", html.button("About")),
)
```

@@ -127,10 +132,16 @@ from reactpy_router import link, route, simple, use_query

@component
def root():
use_location()
return simple.router(
route("/", html.h1("Home Page 🏠")),
route("/search", search()),
link("Search", to="/search?q=reactpy"),
route(
"/",
html.div(
html.h1("Home Page 🏠"),
link("Search", to="/search?q=reactpy"),
),
),
route("/about", html.h1("About Page 📖")),
)

@component
@@ -152,9 +163,14 @@ from reactpy_router import link, route, simple, use_params
@component
def root():
return simple.router(
route("/", html.h1("Home Page 🏠")),
route(
"/",
html.div(
html.h1("Home Page 🏠"),
link("User 123", to="/user/123"),
),
),
route("/user/{id:int}", user()),
link("User 123", to="/user/123"),
)

@component