-
Notifications
You must be signed in to change notification settings - Fork 0
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
Conversation
@@ -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(); |
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.
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"] } |
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.
Note
git
参照だと use_clipboard
の trait 実装のエラーが発生
version
参照とすることで、上記エラーが解決した
(途中から実装された hooks だった場合、バージョンが固定されてないとコンパイル時に解決できないのかも)
arboard
crate を使用する予定だったが、wasm 非対応だったyew-hooks
crate のuse_clipboard
を使用するように対応