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

feat: use_clipboard #18

Merged
merged 4 commits into from
Nov 14, 2023
Merged

Conversation

marc2332
Copy link
Collaborator

No description provided.

@marc2332 marc2332 marked this pull request as ready for review October 15, 2023 10:37
pub fn use_init_clipboard(cx: &ScopeState) {
cx.use_hook(|| {
if let Ok(clipboard) = ClipboardContext::new() {
cx.provide_context(Rc::new(RefCell::new(clipboard)));
Copy link
Member

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

Copy link
Collaborator Author

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

Copy link
Collaborator Author

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

Copy link
Member

@ealmloff ealmloff left a 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!

@marc2332
Copy link
Collaborator Author

Let me clean this up

@DogeDark DogeDark merged commit e0c74cd into DioxusLabs:master Nov 14, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants