Unify the warning system (#2649)

* unify the warning system

* fix VirtualDom::new warning with a component

* move warnings to dioxuslabs

* also allow writes in the component body when converting from T -> ReadOnlySignal<T>

* fix clippy from merge conflict

---------

Co-authored-by: Jonathan Kelley <jkelleyrtp@gmail.com>
This commit is contained in:
Evan AlmloffandJonathan Kelley authored and GitHub committed 2024-07-24 15:50:36 -07:00
1 parent f8cb07e673
commit a6c025c8ef
10 files changed
+132 -63

No files matched your search

+10 -3
View File
@@ -254,8 +254,15 @@ impl VirtualDom {
/// ```
///
/// Note: the VirtualDom is not progressed, you must either "run_with_deadline" or use "rebuild" to progress it.
pub fn new<F: Fn() -> Element + Clone + 'static>(app: F) -> Self {
Self::new_with_props(app, ())
pub fn new(app: fn() -> Element) -> Self {
Self::new_with_props(
move || {
use warnings::Warning;
// The root props don't come from a vcomponent so we need to manually rerun them sometimes
crate::properties::component_called_as_function::allow(app)
},
(),
)
}
/// Create a new VirtualDom with the given properties for the root component.
@@ -313,7 +320,7 @@ impl VirtualDom {
}
/// Create a new virtualdom and build it immediately
pub fn prebuilt<F: Fn() -> Element + Clone + 'static>(app: F) -> Self {
pub fn prebuilt(app: fn() -> Element) -> Self {
let mut dom = Self::new(app);
dom.rebuild_in_place();
dom