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

#15: 生成したQRコード画像をクリップボードへコピーできるように対応 #22

Merged
merged 5 commits into from
Dec 29, 2024

Conversation

ytak-sagit
Copy link
Owner

  • 当初は arboard crate を使用する予定だったが、wasm 非対応だった
  • そのため、yew-hooks crate の use_clipboard を使用するように対応

@ytak-sagit ytak-sagit added the enhancement New feature or request label Dec 29, 2024
@@ -52,6 +53,7 @@ struct QrCodeProps {
#[function_component(QrCodeImage)]
fn qr_code_image(props: &QrCodeProps) -> Html {
let QrCodeProps { url } = props.clone();
let clipboard = use_clipboard();
Copy link
Owner Author

@ytak-sagit ytak-sagit Dec 29, 2024

Choose a reason for hiding this comment

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

Note

hooks は常に呼ばれる形でないと、Hooks was called conditionally. といったエラーが発生する

  • 条件付きで hooks が呼ばれたり呼ばれなかったりするのはNG

@@ -8,4 +8,5 @@ edition = "2021"
[dependencies]
qr-code-wrapper = { path = "./qr-code-wrapper" }
web-sys = "0.3.76"
yew = { git = "https://github.com/yewstack/yew/", features = ["csr"] }
yew = { version = "0.21.0", features = ["csr"] }
Copy link
Owner Author

Choose a reason for hiding this comment

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

Note

git 参照だと use_clipboard の trait 実装のエラーが発生
version 参照とすることで、上記エラーが解決した
(途中から実装された hooks だった場合、バージョンが固定されてないとコンパイル時に解決できないのかも)

@ytak-sagit ytak-sagit merged commit d9952ca into main Dec 29, 2024
@ytak-sagit ytak-sagit deleted the feature/#15-copy-to-clipboard branch December 29, 2024 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

生成したQRコード画像をクリップボードにコピーできるようにする
1 participant