fix: namespacing of dynamic attributes
This commit is contained in:
1 parent
db5b65b6cb
commit
0bf4725639
9 files changed
+24
-31
No files matched your search
@@ -8,6 +8,6 @@ struct AppSettings {}
|
||||
|
||||
// ANCHOR: wrap_context
|
||||
fn use_settings(cx: &ScopeState) -> UseSharedState<AppSettings> {
|
||||
use_context::<AppSettings>(cx).expect("App settings not provided")
|
||||
use_shared_state::<AppSettings>(cx).expect("App settings not provided")
|
||||
}
|
||||
// ANCHOR_END: wrap_context
|
||||
@@ -1,7 +1,6 @@
|
||||
// ANCHOR: all
|
||||
#![allow(non_snake_case)]
|
||||
|
||||
use dioxus::events::FormData;
|
||||
use dioxus::prelude::*;
|
||||
|
||||
fn main() {
|
||||
@@ -14,7 +13,7 @@ struct DarkMode(bool);
|
||||
|
||||
pub fn App(cx: Scope) -> Element {
|
||||
// ANCHOR: context_provider
|
||||
use_context_provider(cx, || DarkMode(false));
|
||||
use_shared_state_provider(cx, || DarkMode(false));
|
||||
// ANCHOR_END: context_provider
|
||||
|
||||
let is_dark_mode = use_is_dark_mode(cx);
|
||||
@@ -37,7 +36,7 @@ pub fn App(cx: Scope) -> Element {
|
||||
|
||||
pub fn use_is_dark_mode(cx: &ScopeState) -> bool {
|
||||
// ANCHOR: use_context
|
||||
let dark_mode_context = use_context::<DarkMode>(cx);
|
||||
let dark_mode_context = use_shared_state::<DarkMode>(cx);
|
||||
// ANCHOR_END: use_context
|
||||
|
||||
dark_mode_context
|
||||
@@ -47,7 +46,7 @@ pub fn use_is_dark_mode(cx: &ScopeState) -> bool {
|
||||
|
||||
// ANCHOR: toggle
|
||||
pub fn DarkModeToggle(cx: Scope) -> Element {
|
||||
let dark_mode = use_context::<DarkMode>(cx)?;
|
||||
let dark_mode = use_shared_state::<DarkMode>(cx).unwrap();
|
||||
|
||||
let style = if dark_mode.read().0 {
|
||||
"color:white"
|
||||
|
||||
Reference in new issue
Block a user