{"record":{"id":"3556fb7da4309a4e","repo":"DioxusLabs/dioxus","slug":"gobackbutton-must-have-access-to-a-parent-router","errorCode":null,"errorMessage":"`GoBackButton` must have access to a parent router","messagePattern":"`GoBackButton` must have access to a parent router","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/router/src/components/history_buttons.rs","lineNumber":72,"sourceCode":"/// # let mut vdom = VirtualDom::new(App);\n/// # vdom.rebuild_in_place();\n/// # assert_eq!(\n/// #     dioxus_ssr::render(&vdom),\n/// #     r#\"<button disabled=\"true\">go back</button>\"#\n/// # );\n/// ```\npub fn GoBackButton(props: HistoryButtonProps) -> Element {\n    let HistoryButtonProps { children } = props;\n\n    // hook up to router\n    let router = match use_router_internal() {\n        Some(r) => r,\n        #[allow(unreachable_code)]\n        None => {\n            let msg = \"`GoBackButton` must have access to a parent router\";\n            error!(\"{msg}, will be inactive\");\n            #[cfg(debug_assertions)]\n            panic!(\"{}\", msg);\n            return VNode::empty();\n        }\n    };\n\n    let disabled = !router.can_go_back();\n\n    rsx! {\n        button {\n            disabled: \"{disabled}\",\n            onclick: move |evt| {\n                evt.prevent_default();\n                router.go_back()\n            },\n            {children}\n        }\n    }\n}\n","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/DioxusLabs/dioxus/blob/24f6a829df0dfa203961a98ea4cae21c2ff27e28/packages/router/src/components/history_buttons.rs#L54-L90","documentation":"GoBackButton called use_router_internal() and got None, meaning no Router ancestor provides router context. In debug builds this panics; in release the button logs the error and renders inactive/disabled since it cannot navigate without a router.","triggerScenarios":"Thrown at packages/router/src/components/history_buttons.rs:72 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Render GoBackButton inside a Router component so it can access the router context."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"24f6a829df0dfa203961a98ea4cae21c2ff27e28","analyzedAt":"2026-08-23T07:10:14.078Z","contentChangedAt":"2026-08-23T07:10:14.078Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}