DioxusLabs/dioxus · error

The tree has not been built yet. Make sure to call rebuild…

Error message

The tree has not been built yet. Make sure to call rebuild on the tree before accessing its nodes.

What it means

Accessed a component's root node before the VirtualDom has ever rendered it. root_node only has data after rebuild/rebuild_absorption has produced output for that scope; querying earlier returns this error.

Solutions

  1. Call `rebuild` (or launch the app normally) before accessing nodes of the VirtualDOM tree; the tree must be built at least once first.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/core/src/scopes.rs:94 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of DioxusLabs/dioxus@24f6a829df (2026-08-23). Data as JSON: /api/errors/d300662f31b168bb. Report an issue: GitHub.

Appendix: source

Thrown at packages/core/src/scopes.rs:94

/// This state erases the type of the component's props. It is used to store the state of a component in the runtime.
pub struct ScopeState {
    pub(crate) runtime: Rc<Runtime>,
    pub(crate) context_id: ScopeId,
    pub(crate) props: BoxedAnyProps,
    /// The last mounted output for this component.
    pub(crate) last_rendered_node: Option<MountedOutput>,
    pub(crate) reactive_context: ReactiveContext,
}

impl ScopeState {
    /// Get a handle to the currently active head node arena for this Scope
    ///
    /// This is useful for traversing the tree outside of the VirtualDom, such as in a custom renderer or in SSR.
    ///
    /// Panics if the tree has not been built yet.
    pub fn root_node(&self) -> &VNode {
        self.try_root_node()
            .expect("The tree has not been built yet. Make sure to call rebuild on the tree before accessing its nodes.")
    }

    /// Try to get a handle to the currently active head node arena for this Scope
    ///
    /// This is useful for traversing the tree outside of the VirtualDom, such as in a custom renderer or in SSR.
    ///
    /// Returns [`None`] if the tree has not been built yet.
    pub fn try_root_node(&self) -> Option<&VNode> {
        match &self.last_rendered_node {
            Some(output) => Some(output.as_vnode()),
            None => None,
        }
    }

    /// Try to get the currently active root node with its mounted identity.
    ///
    /// Returns [`None`] if the tree has not been built or mounted yet.
    pub fn try_mounted_root_node(&self) -> Option<MountedVNode<'_>> {

View on GitHub (pinned to 24f6a829df)