Skip to content

Commit

Permalink
Remove start_app_as_body. (#2346)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

Co-authored-by: Julius Lungys <[email protected]>
  • Loading branch information
futursolo and voidpumpkin authored Jan 10, 2022
1 parent 0ed6cb7 commit 1c367a7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 41 deletions.
15 changes: 0 additions & 15 deletions packages/yew/src/app_handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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()
Expand Down
26 changes: 0 additions & 26 deletions packages/yew/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>(
Expand Down Expand Up @@ -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:
Expand Down
8 changes: 8 additions & 0 deletions website/docs/migration-guides/yew/from-0_19_0-to-0_20_0.mdx
Original file line number Diff line number Diff line change
@@ -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).

0 comments on commit 1c367a7

Please sign in to comment.