In YEW, how to tell it to use just a <div> tag and not the whole page?

I am using the YEW framework and it always replaces all HTML in a page. In many web frameworks, it is possible to inject HTML in just a <div> tag and leave the HTML already in the page untouched. How can I do that in YEW?

I've not used Yew myself, but looking at the source, it seems like mount_to_body (which replaces the whole document body) is just a convenience method for mount, which can target any element in the page.

I am using the following code, but the unwrap().unwrap() part seems a bit verbose is that the correct way of doing it?

let div = document().query_selector("#app").unwrap().unwrap();


mount_to_body also unwraps twice (albeit using expect to provide a bit of a better error message if things go wrong), so you should be fine. If the document or the root element don't exist there's no way the app can start anyway.