DioxusLabs/dioxus · error

Tried to access `Some` on an Option value

Error message

Tried to access `Some` on an Option value

What it means

A Store<Option<T>> operation (like unwrap/expect via transpose) required the Some case but the underlying Option is None. The store was in the None state, so the Some-typed view is unavailable and the guard panics.

Source

Thrown at packages/stores/src/impls/option.rs:92

    /// Transpose the `Store<Option<T>>` into a `Option<Store<T>>`. This will only track the shallow state of the `Option`. It will
    /// only cause a re-run if the `Option` could change from `None` to `Some` or vice versa.
    ///
    /// # Example
    /// ```rust, no_run
    /// use dioxus_stores::*;
    /// let store = use_store(|| Some(42));
    /// let transposed = store.transpose();
    /// match transposed {
    ///     Some(inner_store) => assert_eq!(inner_store(), 42),
    ///     None => panic!("Expected Some"),
    /// }
    /// ```
    pub fn transpose(self) -> Option<MappedStore<T, Lens>> {
        self.is_some().then(move || {
            let map: fn(&Option<T>) -> &T = |value| {
                value.as_ref().unwrap_or_else(|| {
                    panic!("Tried to access `Some` on an Option value");
                })
            };
            let map_mut: fn(&mut Option<T>) -> &mut T = |value| {
                value.as_mut().unwrap_or_else(|| {
                    panic!("Tried to access `Some` on an Option value");
                })
            };
            self.into_selector().child(0, map, map_mut).into()
        })
    }

    /// Unwraps the `Option` and returns a `Store<T>`. This will only track the shallow state of the `Option`. It will
    /// only cause a re-run if the `Option` could change from `None` to `Some` or vice versa.
    ///
    /// # Example
    /// ```rust, no_run
    /// use dioxus_stores::*;
    /// let store = use_store(|| Some(42));

View on GitHub (pinned to 24f6a829df)

Solutions

  1. The Option value is None. Check with pattern matching or as_ref() before accessing the Some payload.
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at packages/stores/src/impls/option.rs:92 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/a85184e885542634. Report an issue: GitHub.