-
-
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
Breaking change: add support for required props #525
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jstarry
commented
Jul 13, 2019
dtolnay
reviewed
Jul 14, 2019
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 don't know much about Yew but I had a quick skim through the macro implementation. Looks nicely written!
jstarry
commented
Jul 14, 2019
jstarry
force-pushed
the
required-props
branch
3 times, most recently
from
July 20, 2019 15:27
7ecf705
to
5c6cbd4
Compare
I cry of happiness. It's amazing!!! |
therustmonk
approved these changes
Jul 23, 2019
bors r+ |
bors bot
added a commit
that referenced
this pull request
Jul 23, 2019
525: Breaking change: add support for required props r=jstarry a=jstarry #### Problem Before this change, properties must implement default which means that even if a prop always gets passed in by value to a component, it still needs a default state in props. No longer! #### Solution This breaking change allows annotating prop fields as required by using a procedural derive macro. #### Notes - If a prop is required, it does not need to implement `Default`. - If a prop is optional (not required), it must now implement `Default`. - If a required prop is not passed into a component, your app will not compile. - Props with lifetime parameters are not supported - Props with generics are supported! #### Breaking changes: 1. Properties must now implement the `Properties` trait by adding `#[derive(Properties)]` to their prop structs 2. Non-required prop fields must implement `Default` 3. Callback props created through the closure syntax will no longer return an `Option` type Depends on #518 Co-authored-by: Justin Starry <jstarry@users.noreply.github.com>
Build failed |
bors r+ |
bors bot
added a commit
that referenced
this pull request
Jul 24, 2019
525: Breaking change: add support for required props r=jstarry a=jstarry #### Problem Before this change, properties must implement default which means that even if a prop always gets passed in by value to a component, it still needs a default state in props. No longer! #### Solution This breaking change allows annotating prop fields as required by using a procedural derive macro. #### Notes - If a prop is required, it does not need to implement `Default`. - If a prop is optional (not required), it must now implement `Default`. - If a required prop is not passed into a component, your app will not compile. - Props with lifetime parameters are not supported - Props with generics are supported! #### Breaking changes: 1. Properties must now implement the `Properties` trait by adding `#[derive(Properties)]` to their prop structs 2. Non-required prop fields must implement `Default` 3. Callback props created through the closure syntax will no longer return an `Option` type Depends on #518 Co-authored-by: Justin Starry <jstarry@users.noreply.github.com>
Build succeeded |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Before this change, properties must implement default which means that even if a prop always gets passed in by value to a component, it still needs a default state in props. No longer!
Solution
This breaking change allows annotating prop fields as required by using a procedural derive macro.
Notes
Default
.Default
.Breaking changes:
Properties
trait by adding#[derive(Properties)]
to their prop structsDefault
Option
typeDepends on #518