-
Notifications
You must be signed in to change notification settings - Fork 13
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
feat: use_clipboard #18
Conversation
src/clipboard/mod.rs
Outdated
pub fn use_init_clipboard(cx: &ScopeState) { | ||
cx.use_hook(|| { | ||
if let Ok(clipboard) = ClipboardContext::new() { | ||
cx.provide_context(Rc::new(RefCell::new(clipboard))); |
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.
We can remove the use_init method here by trying to read the context and then inserting the context at the root if we don't find it. Like the signals crate does here. Then you can just use use_clipboard directly without worrying about the context
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.
We can remove the use_init method here by trying to read the context and then inserting the context at the root if we don't find it. Like the signals crate does here. Then you can just use use_clipboard directly without worrying about the context
Can we though? Last I tried that, it didn't work in nested components. I think it got fixed on the master branch but not released. I might be wrong, I'll try it later
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.
Nevermind, it seems to work just fine... weird 🤔 I'll revisit some of my hooks in freya then
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 great, thank you!
Let me clean this up |
No description provided.