{"record":{"id":"c2c63f81f62c7c5e","repo":"DioxusLabs/dioxus","slug":"the-hook-list-is-already-borrowed-this-error-is-l","errorCode":null,"errorMessage":"The hook list is already borrowed: This error is likely caused by trying to use  hook inside a hook which violates the rules of hooks.","messagePattern":"The hook list is already borrowed: This error is likely caused by trying to use  hook inside a hook which violates the rules of hooks\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/core/src/scope_context.rs","lineNumber":382,"sourceCode":"    /// Queue an effect to run after the next render\n    pub(crate) fn queue_effect(&self, f: impl FnOnce() + 'static) {\n        Runtime::with(|rt| rt.queue_effect(self.id, f));\n    }\n\n    /// Store a value in the hook list, returning the value.\n    pub(crate) fn use_hook<State: Clone + 'static>(\n        &self,\n        initializer: impl FnOnce() -> State,\n    ) -> State {\n        let cur_hook = self.hook_index.get();\n\n        // The hook list works by keeping track of the current hook index and pushing the index forward\n        // while retrieving the hook value.\n        self.hook_index.set(cur_hook + 1);\n\n        let mut hooks = self.hooks\n            .try_borrow_mut()\n            .expect(\"The hook list is already borrowed: This error is likely caused by trying to use  hook inside a hook which violates the rules of hooks.\");\n\n        // Try and retrieve the hook value if it exists\n        if let Some(existing) = self.use_hook_inner::<State>(&mut hooks, cur_hook) {\n            return existing;\n        }\n\n        // Otherwise, initialize the hook value. In debug mode, we allow hook types to change after a hot patch\n        self.push_hook_value(&mut hooks, cur_hook, initializer())\n    }\n\n    // The interior version that gets monomorphized by the `State` type but not the `initializer` type.\n    // This helps trim down binary sizes\n    fn use_hook_inner<State: Clone + 'static>(\n        &self,\n        hooks: &mut Vec<Box<dyn std::any::Any>>,\n        cur_hook: usize,\n    ) -> Option<State> {\n        hooks.get(cur_hook).and_then(|inn| {","sourceCodeStart":364,"sourceCodeEnd":400,"githubUrl":"https://github.com/DioxusLabs/dioxus/blob/24f6a829df0dfa203961a98ea4cae21c2ff27e28/packages/core/src/scope_context.rs#L364-L400","documentation":"Raised when a hook tries to access the scope's hook list while it is already mutably borrowed — classically caused by calling a hook (use_signal, use_state, ...) inside another hook's initializer or from within a component body that is itself borrowing the list. Violates the rules of hooks.","triggerScenarios":"Thrown at packages/core/src/scope_context.rs:382 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Do not call a hook from inside another hook (including inside closures passed to hooks that run synchronously); move the inner hook call to the top level of the component body, following the rules of hooks."],"exampleFix":null,"handlingStrategy":"validation","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-23T08:17:48.524Z"}