Skip to content

How to "dismount" after "leptos::mount_to" #1306

Answered by gbj
jsprog asked this question in Q&A
Discussion options

You must be logged in to vote

Fair enough. I still don't understand what "kill a view" here means, I'm afraid. Sorry for the miscommunication here--it definitely seems like that's a clear question to you and not to me.

One final word, if it's helpful in your life exploration: mount_to just gives you a Scope in the reactive system and expects you to return a View. View is just an enum that wraps a couple different types of, basically, smart pointers to DOM nodes.

I can imagine "kill" meaning

  1. remove from the DOM, and/or
  2. stop the reactive system

These would be achieved by

  1. Element::remove()
  2. Scope::dispose()

So if you

mount_to(|cx| {
  let div = view! { cx,
    <div></div>
  };
  // store cx and div somewhere 
  div
});

Replies: 6 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

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

Comment options

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

Comment options

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

Answer selected by jsprog
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants