Router
A QuickGUI UI projection of QuickGUI core routing with nested layouts and bounded memory history.
Loading interactive demo…
func RouterExample() *native.Node {
return ui.Router(ui.RouterProps{
InitialPath: "/",
Routes: []*ui.RouteDeclaration{
ui.Route(
"/",
func() *native.Node {
return ui.Link(
ui.LinkProps{Href: "/settings"},
"Settings",
)
},
),
ui.Route(
"/settings",
func() *ui.Element { return ui.Text("Settings") },
),
},
Fallback: func() *ui.Element { return ui.Text("Page not found") },
})
}#Import
Import ui from github.com/egoist/quickgui/go/ui.
import (
"github.com/egoist/quickgui/go/ui"
)#Usage
func RouterExample() *native.Node {
return ui.Router(ui.RouterProps{
InitialPath: "/",
Routes: []*ui.RouteDeclaration{
ui.Route(
"/",
func() *native.Node {
return ui.Link(
ui.LinkProps{Href: "/settings"},
"Settings",
)
},
),
ui.Route(
"/settings",
func() *ui.Element { return ui.Text("Settings") },
),
},
Fallback: func() *ui.Element { return ui.Text("Page not found") },
})
}#Anatomy
ui.Routerui.Routeui.Layoutui.Linkui.Outlet
#API reference
Expand an entry for its description and complete signature. A dash means no declaration default is documented.
Router
View sourceui.Router(props RouterProps) *native.NodeRouter renders the route table's matched chain. Declarations never change after creation.
