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
Error on refs on components #2863
Conversation
r#ref is still allowed, so we reserve the right to reintroduce the syntax
Visit the preview URL for this PR (updated for commit ad00979): https://yew-rs-api--pr2863-error-node-refs-dsl9pdzz.web.app (expires Mon, 19 Sep 2022 01:53:54 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 |
The test failures are, as far as I can see, all related to tokio-rs/tokio#4973 |
Benchmark - SSRYew Master
Pull Request
|
Size Comparison
✅ None of the examples has changed their size significantly. |
elem.detach(&root, &parent, false); | ||
scheduler::start_now(); | ||
assert!(node_ref.get().is_none(), "components don't have node refs"); | ||
} |
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.
Test removed because this is now a compile error, see component-fail.stderr above.
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.
Could you please also add a test case to demonstrate that r#ref
would work as expected?
That test exists here already: https://github.com/yewstack/yew/blob/master/packages/yew-macro/tests/html_macro/component-pass.rs#L104 - although weirdly enough it uses |
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.
Looks good.
Description
With #2783,
ref
was removed from components. With this, this is now a compile time error instead of silently not binding a node during runtime, which could lead to unexpectedNone
returned fromget
. This also includes a fix to thenode_refs
example by applying a similar workaround as suggested in the migration notes.Checklist