Egor Makarenko
Egor Makarenko
SSolara
Created by Egor Makarenko on 5/22/2024 in #questions-issues
Is there any way to catch exceptions raised during rendering?
It is strange, but replacing solara.VBox() with rv.Html(tag="div") fixes the use_exception example
6 replies
SSolara
Created by Egor Makarenko on 5/22/2024 in #questions-issues
Is there any way to catch exceptions raised during rendering?
Thank you! I experimented with that a bit and it seems that function components are working too: https://app.py.cafe/snippet/solara/v1?projectId=iqmfu9u0mom
6 replies
SSolara
Created by kakar5178 on 5/26/2024 in #questions-issues
Help Regarding Multi-page
You can look at tabs implementation in solara.AppLayout source code and create your own component with links to pages generated the same way as Solara does. Here is a HeaderMenu component I used to display tabs near the title instead of a separate vuetify slot:
@reacton.component
def HeaderMenu():
route_level = solara.use_route_level()
route, routes = solara.use_route(level=-route_level)
_, set_location_path = solara.use_pathname()
paths = [solara.resolve_path(r, level=0) for r in routes]
index = routes.index(route) if route else None

def set_path(i: int):
path = paths[i]
set_location_path(path)

with rv.Tabs(v_model=index, on_v_model=set_path) as menu:
for route in routes:
name = route.path.capitalize() if route.path != "/" else "Home"
rv.Tab(children=[name])

return menu
@reacton.component
def HeaderMenu():
route_level = solara.use_route_level()
route, routes = solara.use_route(level=-route_level)
_, set_location_path = solara.use_pathname()
paths = [solara.resolve_path(r, level=0) for r in routes]
index = routes.index(route) if route else None

def set_path(i: int):
path = paths[i]
set_location_path(path)

with rv.Tabs(v_model=index, on_v_model=set_path) as menu:
for route in routes:
name = route.path.capitalize() if route.path != "/" else "Home"
rv.Tab(children=[name])

return menu
2 replies
SSolara
Created by animusater on 3/7/2024 in #questions-issues
Interact with `Layout` defined in another file
In React this can be done with portals, and it seems that Reacton also supports this as an undocumented feature. You can see an example in solara.AppLayout, which allows to modify AppBar and AppBarTitle content from any component: https://github.com/widgetti/solara/blob/9e3cdae574a3534d940131504c535ee7a5f59ee0/solara/components/applayout.py#L33C7-L33C20
4 replies