-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document anti-pattrens regarding props #1843
Comments
For a beginner (like me) who also doesn't have any significant frontend / react experience some more general "dos & and don'ts" would also be really helpful. Questions I am uncertain about include stuff like:
|
A section about anti-patterns/what not to do on the Properties page would be enough. |
In #2402, it seems like the consensus was to use some form of It seems to me that the yew::virtual_dom::AttrValue type does the job well, and the ergonomics (implicit conversions) seem to be in place. The only issue I see is that this type is exported by the Is using |
@finnbear Using it generally for attributes of type |
@WorldSEnder I'm pretty sure My recommendations on props:
Unfortunately I haven't work much with functional component yet (I did some react hooks for a client a year ago though) but I think some of the issues with full components are better handled with the hook mechanism. Maybe someone more experimented with functional components in Yew can detail this and compare with the list of recommendations I just did for full components? One last recommendation I have in a more general way: if you worked with React you will be tempted to solve problems the way you usually did with React. Sometimes those solutions don't work at all with Rust and you need to take a step back and think more of the Rust way. For example, in JS we use objects (hashmaps) a lot but in Rust it often makes little sense. (I, for one, almost never use hashmaps.) (Main reason I didn't hook with the hook is because I already had a big code base and lots of habits 😓) |
I think we should document anti-patterns. I would be fine with making a PR for those but first we need to list them.
String
, instead ofCow<'static, str>
as props.From #1834 (comment), as requested by @siku2
The text was updated successfully, but these errors were encountered: