feat: mvoe away from compound context
This commit is contained in:
1 parent
bfdcb20437
commit
a2c7d17b05
103 files changed
+309
-293
No files matched your search
@@ -4,7 +4,7 @@ Render a Dioxus VirtualDOM to a string.
|
||||
|
||||
```rust
|
||||
// Our app:
|
||||
const App: FC<()> = |cx| cx.render(rsx!(div {"hello world!"}));
|
||||
const App: FC<()> = |cx, props|cx.render(rsx!(div {"hello world!"}));
|
||||
|
||||
// Build the virtualdom from our app
|
||||
let mut vdom = VirtualDOM::new(App);
|
||||
|
||||
@@ -12,7 +12,7 @@ fn main() {
|
||||
)
|
||||
}
|
||||
|
||||
pub static App: FC<()> = |cx| {
|
||||
pub static App: FC<()> = |cx, props|{
|
||||
cx.render(rsx!(
|
||||
div {
|
||||
class: "overflow-hidden"
|
||||
|
||||
@@ -40,8 +40,8 @@ struct ExampleProps {
|
||||
initial_name: String,
|
||||
}
|
||||
|
||||
static Example: FC<ExampleProps> = |cx| {
|
||||
let dispaly_name = use_state(cx, move || cx.initial_name.clone());
|
||||
static Example: FC<ExampleProps> = |cx, props| {
|
||||
let dispaly_name = use_state(cx, move || props.initial_name.clone());
|
||||
|
||||
cx.render(rsx! {
|
||||
div { class: "py-12 px-4 text-center w-full max-w-2xl mx-auto",
|
||||
|
||||
@@ -23,7 +23,7 @@ fn main() {
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
pub static App: FC<()> = |cx| {
|
||||
pub static App: FC<()> = |cx, props|{
|
||||
cx.render(rsx!(
|
||||
div { class: "overflow-hidden"
|
||||
link { href:"https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css" rel:"stylesheet" }
|
||||
@@ -38,7 +38,7 @@ pub static App: FC<()> = |cx| {
|
||||
))
|
||||
};
|
||||
|
||||
pub static Header: FC<()> = |cx| {
|
||||
pub static Header: FC<()> = |cx, props|{
|
||||
cx.render(rsx! {
|
||||
div {
|
||||
header { class: "text-gray-400 bg-gray-900 body-font"
|
||||
@@ -64,7 +64,7 @@ pub static Header: FC<()> = |cx| {
|
||||
})
|
||||
};
|
||||
|
||||
pub static Hero: FC<()> = |cx| {
|
||||
pub static Hero: FC<()> = |cx, props|{
|
||||
//
|
||||
cx.render(rsx! {
|
||||
section{ class: "text-gray-400 bg-gray-900 body-font"
|
||||
@@ -102,7 +102,7 @@ pub static Hero: FC<()> = |cx| {
|
||||
}
|
||||
})
|
||||
};
|
||||
pub static Entry: FC<()> = |cx| {
|
||||
pub static Entry: FC<()> = |cx, props|{
|
||||
//
|
||||
cx.render(rsx! {
|
||||
section{ class: "text-gray-400 bg-gray-900 body-font"
|
||||
@@ -115,7 +115,7 @@ pub static Entry: FC<()> = |cx| {
|
||||
})
|
||||
};
|
||||
|
||||
pub static StacksIcon: FC<()> = |cx| {
|
||||
pub static StacksIcon: FC<()> = |cx, props|{
|
||||
cx.render(rsx!(
|
||||
svg {
|
||||
// xmlns: "http://www.w3.org/2000/svg"
|
||||
@@ -130,7 +130,7 @@ pub static StacksIcon: FC<()> = |cx| {
|
||||
}
|
||||
))
|
||||
};
|
||||
pub static RightArrowIcon: FC<()> = |cx| {
|
||||
pub static RightArrowIcon: FC<()> = |cx, props|{
|
||||
cx.render(rsx!(
|
||||
svg {
|
||||
fill: "none"
|
||||
|
||||
@@ -44,7 +44,7 @@ pub fn render_vdom_scope(vdom: &VirtualDom, scope: ScopeId) -> Option<String> {
|
||||
///
|
||||
/// ## Example
|
||||
/// ```ignore
|
||||
/// static App: FC<()> = |cx| cx.render(rsx!(div { "hello world" }));
|
||||
/// static App: FC<()> = |cx, props|cx.render(rsx!(div { "hello world" }));
|
||||
/// let mut vdom = VirtualDom::new(App);
|
||||
/// vdom.rebuild();
|
||||
///
|
||||
@@ -242,13 +242,13 @@ mod tests {
|
||||
use dioxus_core::prelude::*;
|
||||
use dioxus_html as dioxus_elements;
|
||||
|
||||
static SIMPLE_APP: FC<()> = |cx| {
|
||||
static SIMPLE_APP: FC<()> = |cx, props|{
|
||||
cx.render(rsx!(div {
|
||||
"hello world!"
|
||||
}))
|
||||
};
|
||||
|
||||
static SLIGHTLY_MORE_COMPLEX: FC<()> = |cx| {
|
||||
static SLIGHTLY_MORE_COMPLEX: FC<()> = |cx, props|{
|
||||
cx.render(rsx! {
|
||||
div {
|
||||
title: "About W3Schools"
|
||||
@@ -267,14 +267,14 @@ mod tests {
|
||||
})
|
||||
};
|
||||
|
||||
static NESTED_APP: FC<()> = |cx| {
|
||||
static NESTED_APP: FC<()> = |cx, props|{
|
||||
cx.render(rsx!(
|
||||
div {
|
||||
SIMPLE_APP {}
|
||||
}
|
||||
))
|
||||
};
|
||||
static FRAGMENT_APP: FC<()> = |cx| {
|
||||
static FRAGMENT_APP: FC<()> = |cx, props|{
|
||||
cx.render(rsx!(
|
||||
div { "f1" }
|
||||
div { "f2" }
|
||||
@@ -330,7 +330,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn styles() {
|
||||
static STLYE_APP: FC<()> = |cx| {
|
||||
static STLYE_APP: FC<()> = |cx, props|{
|
||||
cx.render(rsx! {
|
||||
div { style: { color: "blue", font_size: "46px" } }
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user