Skip to content

Commit 3fefc8d

Browse files
authored
Fix link usages (#21)
* Fix link usages. * remove run()
1 parent 00974fa commit 3fefc8d

File tree

1 file changed

+26
-10
lines changed

1 file changed

+26
-10
lines changed

docs/src/usage.md

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,21 @@ This will allow ReactPy to handle the transition between routes more quickly by
9292
the cost of a full page load.
9393

9494
```python
95-
from reactpy import component, html, run
96-
from reactpy_router import link, route, simple, use_location
95+
from reactpy import component, html, run, use_location
96+
from reactpy_router import link, route, simple
9797

9898
@component
9999
def root():
100-
location = use_location()
100+
use_location()
101101
return simple.router(
102-
route("/", html.h1("Home Page 🏠")),
102+
route(
103+
"/",
104+
html.div(
105+
html.h1("Home Page 🏠"),
106+
link(html.button("About"), to="/about"),
107+
),
108+
),
103109
route("/about", html.h1("About Page 📖")),
104-
link("/about", html.button("About")),
105110
)
106111
```
107112

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

128133
@component
129134
def root():
135+
use_location()
130136
return simple.router(
131-
route("/", html.h1("Home Page 🏠")),
132-
route("/search", search()),
133-
link("Search", to="/search?q=reactpy"),
137+
route(
138+
"/",
139+
html.div(
140+
html.h1("Home Page 🏠"),
141+
link("Search", to="/search?q=reactpy"),
142+
),
143+
),
144+
route("/about", html.h1("About Page 📖")),
134145
)
135146

136147
@component
@@ -152,9 +163,14 @@ from reactpy_router import link, route, simple, use_params
152163
@component
153164
def root():
154165
return simple.router(
155-
route("/", html.h1("Home Page 🏠")),
166+
route(
167+
"/",
168+
html.div(
169+
html.h1("Home Page 🏠"),
170+
link("User 123", to="/user/123"),
171+
),
172+
),
156173
route("/user/{id:int}", user()),
157-
link("User 123", to="/user/123"),
158174
)
159175

160176
@component

0 commit comments

Comments
 (0)