Skip to content

How to implement window onresize callback implementation (yew 0.19.3)? #2815

Answered by WorldSEnder
fstuess asked this question in Q&A
Discussion options

You must be logged in to vote

You can create a gloo::events::EventListener::new(&gloo::utils::window(), "resize", todo!("callback function here")) manually. If you use function components, this could look something like

use_effect(|| {
    let handler = gloo::events::EventListener::new(&gloo::utils::window(), "resize", todo!("callback function here"));
    || { drop(handler); } // Make sure to keep it alive until the component unmounts
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@fstuess
Comment options

Answer selected by fstuess
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants