Skip to content

Commit

Permalink
docs: fix mistakes in code examples for routing
Browse files Browse the repository at this point in the history
Fixes #616
  • Loading branch information
maartenbreddels committed Apr 26, 2024
1 parent a9665b4 commit fa1e807
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ If you do define a `Page` component, you are fully responsible for how routing i
An example route definition could be something like this:

```python
import solara as sol
import solara

routes = [
# route level == 0
Expand Down Expand Up @@ -103,7 +103,7 @@ routes = [
@solara.component
def Page():
level = solara.use_route_level() # returns 0
route_current, routes_current_level = solara.use_routes()
route_current, routes_current_level = solara.use_route()
# route_current is routes[1], i.e. solara.Route(path="docs", children=[...])
# routes_current_level is [routes[0], routes[1], routes[2], routes[3]], i.e.:
# [solara.Route(path="/"), solara.Route(path="docs", children=[...]),
Expand All @@ -125,7 +125,7 @@ Now the `MyFirstLevelChildComponent` component is responsible for rendering the
@solara.component
def MyFirstLevelChildComponent():
level = solara.use_route_level() # returns 1
route_current, routes_current_level = solara.use_routes()
route_current, routes_current_level = solara.use_route()
# route_current is routes[1].children[0], i.e. solara.Route(path="basics", children=[...])
# routes_current_level is [routes[1].children[0], routes[1].children[1]], i.e.:
# [solara.Route(path="basics", children=[...]), solara.Route(path="advanced")]
Expand All @@ -143,7 +143,7 @@ And the `MySecondLevelChildComponent` component is responsible for rendering the
@solara.component
def MySecondLevelChildComponent():
level = solara.use_route_level() # returns 2
route_current, routes_current_level = solara.use_routes()
route_current, routes_current_level = solara.use_route()
# route_current is routes[1].children[0].children[0], i.e. solara.Route(path="react")
# routes_current_level is [routes[1].children[0].children[0], routes[1].children[0].children[1], routes[1].children[0].children[2]], i.e.
# [solara.Route(path="react"), solara.Route(path="ipywidgets"), solara.Route(path="solara")]
Expand Down

0 comments on commit fa1e807

Please sign in to comment.