wip: prepare to change our fragment pattern. Add some more docs

This commit is contained in:
Jonathan Kelley committed 2021-12-18 15:17:32 -05:00
1 parent 2b928372fb
commit 2c3a046426
10 files changed
+108 -71

No files matched your search

+2 -1
View File
@@ -51,9 +51,10 @@ dioxus-html = { path = "../html" }
fern = { version = "0.6.0", features = ["colored"] }
rand = { version = "0.8.4", features = ["small_rng"] }
simple_logger = "1.13.0"
dioxus-core-macro = { path = "../core-macro", version ="^0.1.2"}
dioxus-core-macro = { path = "../core-macro", version = "^0.1.2" }
# dioxus-hooks = { path = "../hooks" }
criterion = "0.3.5"
thiserror = "1.0.30"
[features]
default = []
+10
View File
@@ -0,0 +1,10 @@
//! Handling errors and early aborts
//!
//!
//!
//!
use dioxus_core::prelude::*;
use thiserror::Error;
fn main() {}
+40
View File
@@ -20,7 +20,47 @@ pub(crate) mod innerlude {
pub(crate) use crate::scopearena::*;
pub use crate::virtual_dom::*;
/// An [`Element`] is a possibly-none [`VNode`] created by calling `render` on [`Scope`] or [`ScopeState`].
///
/// Any [`None`] [`Element`] will automatically be coerced into a placeholder [`VNode`] with the [`VNode::Placeholder`] variant.
pub type Element<'a> = Option<VNode<'a>>;
/// A [`Component`] is a function that takes a [`Scope`] and returns an [`Element`].
///
/// Components can be used in other components with two syntax options:
/// - lowercase as a function call with named arguments (rust style)
/// - uppercase as an element (react style)
///
/// ## Rust-Style
///
/// ```rust
/// fn example(cx: Scope<Props>) -> Element {
/// // ...
/// }
///
/// rsx!(
/// example()
/// )
/// ```
/// ## React-Style
/// ```rust
/// fn Example(cx: Scope<Props>) -> Element {
/// // ...
/// }
///
/// rsx!(
/// Example {}
/// )
/// ```
///
/// ## As a closure
/// This particular type alias lets you even use static closures for pure/static components:
///
/// ```rust
/// static Example: Component<Props> = |cx| {
/// // ...
/// };
/// ```
pub type Component<P> = for<'a> fn(Scope<'a, P>) -> Element<'a>;
}