mirror of
https://github.com/yewstack/yew.git
synced 2025-12-08 21:26:25 +00:00
Remove start_app_as_body. (#2346)
* Remove start_app_as_body. * Add migration guide. * Update website/docs/migration-guides/yew/from-0_19_0-to-0_20_0.mdx Co-authored-by: Julius Lungys <32368314+voidpumpkin@users.noreply.github.com> Co-authored-by: Julius Lungys <32368314+voidpumpkin@users.noreply.github.com>
This commit is contained in:
parent
0ed6cb7617
commit
1c367a7b6f
@ -4,7 +4,6 @@
|
||||
use std::ops::Deref;
|
||||
|
||||
use crate::html::{BaseComponent, NodeRef, Scope, Scoped};
|
||||
use gloo_utils::document;
|
||||
use std::rc::Rc;
|
||||
use web_sys::Element;
|
||||
|
||||
@ -34,20 +33,6 @@ where
|
||||
app
|
||||
}
|
||||
|
||||
/// Alternative to `mount_with_props` which replaces the body element with a component which
|
||||
/// has a body element at the root of the HTML generated by its `view` method. Use this method
|
||||
/// when you need to manipulate the body element. For example, adding/removing app-wide
|
||||
/// CSS classes of the body element.
|
||||
pub(crate) fn mount_as_body_with_props(props: Rc<COMP::Properties>) -> Self {
|
||||
let html_element = document().document_element().unwrap();
|
||||
let body_element = document().body().expect("no body node found");
|
||||
html_element
|
||||
.remove_child(&body_element)
|
||||
.expect("can't remove body child");
|
||||
|
||||
Self::mount_with_props(html_element, props)
|
||||
}
|
||||
|
||||
/// Schedule the app for destruction
|
||||
pub fn destroy(mut self) {
|
||||
self.scope.destroy()
|
||||
|
||||
@ -324,19 +324,6 @@ where
|
||||
start_app_with_props(COMP::Properties::default())
|
||||
}
|
||||
|
||||
/// The main entry point of a Yew application.
|
||||
/// Alternative to `start_app` which replaces the body element with a component which has a body
|
||||
/// element at the root of the HTML generated by its `view` method. Use this method when you
|
||||
/// need to manipulate the body element. For example, adding/removing app-wide
|
||||
/// CSS classes of the body element.
|
||||
pub fn start_app_as_body<COMP>() -> AppHandle<COMP>
|
||||
where
|
||||
COMP: BaseComponent,
|
||||
COMP::Properties: Default,
|
||||
{
|
||||
start_app_with_props_as_body(COMP::Properties::default())
|
||||
}
|
||||
|
||||
/// The main entry point of a Yew application. This function does the
|
||||
/// same as `start_app_in_element(...)` but allows to start an Yew application with properties.
|
||||
pub fn start_app_with_props_in_element<COMP>(
|
||||
@ -365,19 +352,6 @@ where
|
||||
)
|
||||
}
|
||||
|
||||
/// The main entry point of a Yew application.
|
||||
/// Alternative to `start_app_with_props` which replaces the body element with a component which has a body
|
||||
/// element at the root of the HTML generated by its `view` method. Use this method when you
|
||||
/// need to manipulate the body element. For example, adding/removing app-wide
|
||||
/// CSS classes of the body element.
|
||||
pub fn start_app_with_props_as_body<COMP>(props: COMP::Properties) -> AppHandle<COMP>
|
||||
where
|
||||
COMP: BaseComponent,
|
||||
{
|
||||
set_default_panic_hook();
|
||||
AppHandle::<COMP>::mount_as_body_with_props(Rc::new(props))
|
||||
}
|
||||
|
||||
/// The Yew Prelude
|
||||
///
|
||||
/// The purpose of this module is to alleviate imports of many common types:
|
||||
|
||||
@ -0,0 +1,8 @@
|
||||
---
|
||||
title: "From 0.19.0 to 0.20.0"
|
||||
---
|
||||
|
||||
## `_as_body` variant of `start_app` is removed
|
||||
|
||||
This method of controlling body has caused issues in event registration and
|
||||
SSR hydration. They have been removed. Read more in the [github issue](https://github.com/yewstack/yew/pull/2346).
|
||||
Loading…
x
Reference in New Issue
Block a user