leptos-rs / book

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

Leptos Book - Reader Feedback: Please Comment Here #48

Open diversable opened 10 months ago

diversable commented 10 months ago

If you have feedback while reading the Leptos book (if something is unclear, or you have suggestions for improvement, etc), please leave a comment on this issue.

Your feedback is greatly appreciated.

Sincerely,

@diversable / Daniel

ydirson commented 10 months ago

My notes:

in https://book.leptos.dev/view/05_forms.html#uncontrolled-inputs maybe something is missing: the first code block uses Input without explaining where it comes from (though we can likely guess guess a bit, pointers to the other types that could be used in NodeRef<...> could be nice) - use leptos::html::Input can be found in the CodeSandbox example but that's much further down the page

It could be useful to move the existing CodeSandbox closer to the code it's showcasing, and maybe use a second one for the <select> example

maybe it would be easier to understand the on_submit callback, by showing the view! {...} code first: at first read I missed the link between input_element and the actual element

in https://book.leptos.dev/view/05_forms.html#textarea, untrack() is used without getting explained

last example in https://book.leptos.dev/view/05_forms.html#select uses a syntax that was not introduced first: <SelectOption value ...>

thinking I had understood the latter I tried to replace <progress max=max ...> with max in the example from https://book.leptos.dev/view/03_components.html but this seems to be interpreted as max=0 instead, maybe a word on this would be useful: I did not even realize I was comparing different beasts, precisely since components do look like elements

tahoeschrader commented 10 months ago

My one piece of feedback at the moment is that I'm looking forward to a page on using Leptos with Tauri

ydirson commented 10 months ago

In https://book.leptos.dev/reactivity/working_with_signals.html#getting-and-setting, "Take a look at the with! docs, and..." would be nice with a link to that doc

In https://book.leptos.dev/reactivity/14_create_effect.html#explicit-cancelable-tracking-with-watch:

cldershem commented 10 months ago

I had a similar issue as someone already stated previously...in 3.6 Input and SubmitEvent come out of nowhere.

I also didn't really care for 3.4's explanation of <For>. Almost all of that is done in a code example with just comments and it doesn't really have the same depth as I think it might need. It's a little difficult to follow.

In the router section the sentence at the beginning is incomplete. "First things first, make sure you’ve added the leptos_router package to your dependencies." doesn't mention that you are required to add at least 1 feature to leptos_router.

ydirson commented 9 months ago

In https://book.leptos.dev/router/16_routes.html#defining-routes-1 the example description states "If you go to /users/3 or /blahblah you’ll get a user profile or your 404 page", it is not obvious why the <Route path="/users/:id" view=UserProfile/> would not take care of the former.

Also the allowed ways to assemble the fragments in Route doc is not necessarily obvious. Especially I'm still baffled by the *any fragment that appears as exemple both in the book and in the doc - that can look like a usual pattern matching "any chars then literal a, n, y, but as that would be a bit arbitrary it could as easily be some sort of "magical string".

ydirson commented 9 months ago

Trying to play with routes, when I finally get a first app to compile, I get a runtime failure teaching You must call use_router() within a <Router/> component Location (sic, the line pointed to calls use_query)

Both https://book.leptos.dev/router/16_routes.html#providing-the-router and https://docs.rs/leptos_router/latest/leptos_router/fn.Router.html# give very little info on the role of this component. I did place it "near the root of the application", but nothing told me that I would not be able to call use_query from my root component.

Wollaston commented 9 months ago

Hi all,

First, thank you for the work to put this book together. It has been really helpful in using Leptos of course, but also in using certain Rust concepts in both a practical and a Wasm context.

A few thoughts and suggestions from me, based on documentation I have read outside of the book that I think would be helpful if included in some manner within the book (from my review, these were not in the book - apologies if I missed something). I am happy to make a PR to add any or all of these, and I can split this list off into its own tracking issue if that would be helpful. Just let me know whatever is preferred and most helpful for you. I deferred to starting in this thread before opening anything new.

Some of these are noted in other threads already and in open issues, but at least for me, I wanted to volunteer myself to tackle the list below that I came across in my own work and wanted a section in the book for.

Again, I can make a new tracking issue for whatever people think should be added to the book, and then make those PRs in turn. But before heading down that path, I wanted to make sure others thought it made sense to include these items. In my opinion, since these are part of core Leptos, it makes sense to have them at least introduced in the main book. I don't think it will add too much maintenance burden, since it's mostly just consolidating existing documentation and examples to the book, but I would love to hear what core maintainers think, and then I can adjust accordingly. Thank you again!

akiross commented 8 months ago

Hello, I'm at the very beginning of looking into leptos and it looks cool! Just a simple question, which came natural to me, but I didn't find mentioned while reading: in https://book.leptos.dev/view/01_basic_component.html#a-basic-component why use the update method instead of the more intuitive following code?

move |_| { set_count(count() + 1); }

I tried and it works, it even makes sense given what it is said in that chapter, but I guess there are some gotchas that I probably can't see now, related to borrowing or moving. Here's the code I've being play with:

use leptos::*;

fn main() {
    let (count, set_count) = create_signal(0);

    mount_to_body(move || {
        view! {
            <input type="text" on:input=move |_| { set_count(count() + 1) }/>
            <p>{ move || count() } "keystrokes"</p>
        }
    })
}

Edit:

I found an answer on the reference doc, where it seems possible, but it is not efficient. I think it's worth to mention that in the book as well and maybe explain why it is not efficient.

ydirson commented 8 months ago

I think it's worth to mention that in the book as well and maybe explain why it is not efficient.

The book has some explanations spread in this page which also points to reference doc. Maybe the reference doc could be enriched to make things clear there too?

connec commented 5 months ago

Unless I'm missing something, the documentation for <select> is misleading, or at least a bit too strong, when it comes to the value property.

The ; if you try this in Leptos (or vanilla JavaScript) it won’t work.

I haven't tried to use it in Leptos, so I can't confirm or deny the last point, but the value property for HTMLSelectElement is documented:

The HTMLSelectElement.value property contains the value of the first selected <option> element associated with this <select> element.

This property can also be set directly, for example to set a default value based on some condition.

gbj commented 5 months ago

Unless I'm missing something, the documentation for <select> is misleading, or at least a bit too strong.

Thanks, I've updated that section and example.