-
-
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
Communication Examples #2856
Communication Examples #2856
Conversation
Size Comparison
✅ None of the examples has changed their size significantly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I appreciate the examples. While I think much of the grandparent-with-grandchildren example is contained in the context
example already, it's more easily discovered through this naming convention, so I wouldn't mind having both.
A few comments about code organization, and I'm not 100% sure how the current layout is handled by the CI and live deployment on examples.yew.rs
(which doesn't have an index, but see e.g. https://examples.yew.rs/boids/)
let (state, _listener) = ctx | ||
.link() | ||
.context::<Rc<AppState>>(ctx.link().callback(ChildMsg::ContextChanged)) | ||
.expect("context to be set"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be good to have a FunctionChild
that shows the usage of use_context
for comparison and completeness.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get your point, but keeping the communication examples structurally the same helps people spot the differences between them.
The use of use_context
in a functional component is demonstrated by the examples/contexts
example. Maybe we can include a comment here to point this out explicitly: "See the context
example for a demonstration of the use of contexts in a functional component." ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah a comment sounds good, I agree that a single style is easier to read.
I've included the comment on the use of the context in a functional component and squashed the commits. |
Communication Examples Updated based on feedback Include communication examples Formatted with +nightly
Description
A set of examples to demonstrate various ways to communicate between components. These cover:
Fixes #2197
Checklist