leptos-rs / book

The home for the Leptos book, which can be found deployed at https://book.leptos.dev
MIT License
80 stars 61 forks source link

fix: code example in dynamic styles #99

Closed 0x616e6f73 closed 4 months ago

0x616e6f73 commented 4 months ago

given

let (x, set_x) = create_signal(0);

x is of type ReadSignal<i32>, a read-only reference to the signal value. the current example calls x, rather than x.get() (the get method to retrieve the value of the signal) yielding the following error:

expected function, found ReadSignal<{integer}>

this pr adds the .get() method call on applicable instances of x.

gbj commented 4 months ago

The book is using the function-call syntax enabled by the nightly feature, as it says in the intro. If it's not compiling for you, maybe you're not?

0x616e6f73 commented 4 months ago

you're spot on. i switched to nightly, and noticed that both #[component] and view! were flagged by the rust-analyzer because "no proc-macros present for crate".

is this supposed to be the case, or a by product of a missed installation step in the pages prior?

gbj commented 4 months ago

I suspect that's just rust-analyzer taking a while to catch up to you, it should not be a longer-term issue. (Sometimes restarting rust-analyzer in your editor, or doing a cargo clean, can help with this sort of ephemeral issue.)

0x616e6f73 commented 4 months ago

understood, thank you!