Skip to content
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

Refactor use ref hooks #2093

Merged
merged 3 commits into from
Nov 21, 2021
Merged

Refactor use ref hooks #2093

merged 3 commits into from
Nov 21, 2021

Conversation

mc1098
Copy link
Contributor

@mc1098 mc1098 commented Sep 30, 2021

use_ref has been renamed to use_mut_ref and use_ref has become a
similar hook for immutable reference.

This is different from React but I think lines up nicely with Rust as a
reference is immutable unless specified to be a mut ref.

This PR also adds use_node_ref which is a specialised version of use_ref
for NodeRef - it is more ergonomic to have this separate hook and it avoids
the need of wrapping an Rc value in another Rc.

Description

Fixes #1642

Checklist

  • I have run cargo make pr-flow
  • I have reviewed my own code
  • I have added tests

`use_ref` has been renamed to `use_mut_ref` and `use_ref` has become a
similar hook for immutable reference.

This is different from React but I think lines up nicely with Rust as a
reference is immutable unless specified to be a mut ref.
@github-actions
Copy link

github-actions bot commented Sep 30, 2021

Visit the preview URL for this PR (updated for commit 8b64369):

https://yew-rs--pr2093-use-ref-6ujaz3md.web.app

(expires Sun, 28 Nov 2021 12:57:22 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

@mc1098 mc1098 added the A-yew Area: The main yew crate label Sep 30, 2021
@mc1098 mc1098 closed this Nov 1, 2021
@ranile ranile reopened this Nov 21, 2021
@ranile
Copy link
Member

ranile commented Nov 21, 2021

I'm going to take over this PR. Hopefully we can land it quickly for 0.19

Copy link
Member

@ranile ranile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

ranile
ranile previously approved these changes Nov 21, 2021
Copy link
Member

@voidpumpkin voidpumpkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

love this

@voidpumpkin
Copy link
Member

@hamza1311 btw if you want this merged you can just approve, since this PR is not yours :D

@mc1098
Copy link
Contributor Author

mc1098 commented Nov 21, 2021

I would approve but it is my PR 🙃

@ranile
Copy link
Member

ranile commented Nov 21, 2021

I would approve but it is my PR 🙃

I will approve it instead

@voidpumpkin voidpumpkin merged commit 071f1b2 into yewstack:master Nov 21, 2021
@mc1098 mc1098 deleted the use_ref branch November 21, 2021 14:21
Madoshakalaka pushed a commit to Madoshakalaka/yew that referenced this pull request Nov 23, 2021
* Refactor use ref hooks

`use_ref` has been renamed to `use_mut_ref` and `use_ref` has become a
similar hook for immutable reference.

This is different from React but I think lines up nicely with Rust as a
reference is immutable unless specified to be a mut ref.

* fix CI

Co-authored-by: Hamza <muhammadhamza1311@gmail.com>

(cherry picked from commit 071f1b2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-yew Area: The main yew crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Integrate use_ref with NodeRef
3 participants