Skip to content

Commit 4de16c4

Browse files
committed
docs: update local examples and docs to support new syntaxes
1 parent e495b09 commit 4de16c4

File tree

118 files changed

+519
-1153
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+519
-1153
lines changed

.vscode/settings.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
{
2-
"rust-analyzer.cargo.allFeatures": true
2+
"rust-analyzer.cargo.allFeatures": true,
3+
"rust-analyzer.cargo.features": [
4+
"desktop",
5+
"router"
6+
],
37
}

README.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
Dioxus is a portable, performant, and ergonomic framework for building cross-platform user experiences in Rust.
5050

5151
```rust
52-
fn App(cx: Scope<()>) -> Element {
52+
fn app(cx: Scope<()>) -> Element {
5353
let mut count = use_state(&cx, || 0);
5454

5555
cx.render(rsx!(
@@ -76,23 +76,21 @@ If you know React, then you already know Dioxus.
7676

7777
<table style="width:100%" align="center">
7878
<tr >
79-
<th><a href="http://github.com/jkelleyrtp/dioxus">Web</a></th>
80-
<th><a href="http://github.com/jkelleyrtp/dioxus">Desktop</a></th>
81-
<th><a href="http://github.com/jkelleyrtp/dioxus">Mobile</a></th>
82-
<th><a href="http://github.com/jkelleyrtp/dioxus">State</a></th>
83-
<th><a href="http://github.com/jkelleyrtp/dioxus">Docs</a></th>
84-
<th><a href="http://github.com/jkelleyrtp/dioxus">Tools</a></th>
79+
<th><a href="https://dioxuslabs.com/book/">Web</a></th>
80+
<th><a href="https://dioxuslabs.com/book/">Desktop</a></th>
81+
<th><a href="https://dioxuslabs.com/book/">Mobile</a></th>
82+
<th><a href="https://dioxuslabs.com/book/">State</a></th>
83+
<th><a href="https://dioxuslabs.com/book/">Docs</a></th>
84+
<th><a href="https://dioxuslabs.com/book/">Tools</a></th>
8585
<tr>
8686
</table>
8787

8888
## Examples:
8989

90-
| File Navigator (Desktop) | Bluetooth scanner (Desktop) | TodoMVC (All platforms) | Widget Gallery |
90+
| File Navigator (Desktop) | Bluetooth scanner (Desktop) | TodoMVC (All platforms) | Tailwind (Liveview) |
9191
| --------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
9292
| [![asd](https://github.com/DioxusLabs/file-explorer-example/raw/master/image.png)](https://github.com/DioxusLabs/file-explorer-example) | [![asd](https://github.com/DioxusLabs/file-explorer-example/raw/master/image.png)](https://github.com/DioxusLabs/file-explorer-example) | [![asd](https://github.com/DioxusLabs/todomvc/raw/master/example.png)](https://github.com/dioxusLabs/todomvc/) | [![asd](https://github.com/DioxusLabs/file-explorer-example/raw/master/image.png)](https://github.com/DioxusLabs/file-explorer-example) |
9393

94-
<!-- | ![asd](https://github.com/DioxusLabs/todomvc/blob/master/example.png) | [![asd](https://github.com/DioxusLabs/todomvc/blob/master/example.png)](https://github.com/dioxusLabs/todomvc/) | ![asd](https://sixtyfps.io/resources/printerdemo_screenshot.png) | -->
95-
9694

9795
See the awesome-dioxus page for a curated list of content in the Dioxus Ecosystem.
9896

@@ -169,6 +167,7 @@ Dioxus is heavily inspired by React, but we want your transition to feel like an
169167
| 1st class global state ||| redux/recoil/mobx on top of context |
170168
| Runs natively ||| runs as a portable binary w/o a runtime (Node) |
171169
| Subtree Memoization ||| skip diffing static element subtrees |
170+
| High-efficiency templates | 🛠 || rsx! calls are translated to templates on the DOM's side |
172171
| Compile-time correct ||| Throw errors on invalid template layouts |
173172
| Heuristic Engine ||| track component memory usage to minimize future allocations |
174173
| Fine-grained reactivity | 👀 || Skip diffing for fine-grain updates |

docs/guide/src/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
```rust
88
fn App(cx: Context, props: &()) -> Element {
9-
let mut count = use_state(cx, || 0);
9+
let mut count = use_state(&cx, || 0);
1010

1111
cx.render(rsx!(
1212
h1 { "High-Five counter: {count}" }
@@ -53,7 +53,7 @@ Dioxus supports server-side rendering!
5353
For rendering statically to an `.html` file or from a WebServer, then you'll want to make sure the `ssr` feature is enabled in the `dioxus` crate and use the `dioxus::ssr` API. We don't expect the SSR API to change drastically in the future.
5454

5555
```rust
56-
let contents = dioxus::ssr::render_vdom(&dom, |c| c);
56+
let contents = dioxus::ssr::render_vdom(&dom);
5757
```
5858

5959
[Jump to the getting started guide for SSR.]()

docs/guide/src/concepts/00-index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ As the UI grows in scale, our logic to keep each element in the proper state wou
4545
Instead, with Dioxus, we *declare* what we want our UI to look like:
4646

4747
```rust
48-
let mut state = use_state(cx, || "red");
48+
let mut state = use_state(&cx, || "red");
4949

5050
cx.render(rsx!(
5151
Container {

docs/guide/src/concepts/11-arena-memo.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ fn test() -> DomTree {
2121
}
2222
}
2323

24-
static TestComponent: FC<()> = |cx, props|html!{<div>"Hello world"</div>};
24+
static TestComponent: Component<()> = |cx, props|html!{<div>"Hello world"</div>};
2525

26-
static TestComponent: FC<()> = |cx, props|{
26+
static TestComponent: Component<()> = |cx, props|{
2727
let g = "BLAH";
2828
html! {
2929
<div> "Hello world" </div>
3030
}
3131
};
3232

3333
#[functional_component]
34-
static TestComponent: FC<{ name: String }> = |cx, props|html! { <div> "Hello {name}" </div> };
34+
static TestComponent: Component<{ name: String }> = |cx, props|html! { <div> "Hello {name}" </div> };
3535
```
3636

3737
## Why this behavior?

docs/guide/src/concepts/12-signals.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Your component today might look something like this:
1212

1313
```rust
1414
fn Comp(cx: Context<()>) -> DomTree {
15-
let (title, set_title) = use_state(cx, || "Title".to_string());
15+
let (title, set_title) = use_state(&cx, || "Title".to_string());
1616
cx.render(rsx!{
1717
input {
1818
value: title,
@@ -26,7 +26,7 @@ This component is fairly straightforward - the input updates its own value on ev
2626

2727
```rust
2828
fn Comp(cx: Context<()>) -> DomTree {
29-
let (title, set_title) = use_state(cx, || "Title".to_string());
29+
let (title, set_title) = use_state(&cx, || "Title".to_string());
3030
cx.render(rsx!{
3131
div {
3232
input {
@@ -96,7 +96,7 @@ Sometimes you want a signal to propagate across your app, either through far-awa
9696

9797
```rust
9898
const TITLE: Atom<String> = || "".to_string();
99-
const Provider: FC<()> = |cx, props|{
99+
const Provider: Component<()> = |cx, props|{
100100
let title = use_signal(&cx, &TITLE);
101101
rsx!(cx, input { value: title })
102102
};
@@ -105,7 +105,7 @@ const Provider: FC<()> = |cx, props|{
105105
If we use the `TITLE` atom in another component, we can cause updates to flow between components without calling render or diffing either component trees:
106106

107107
```rust
108-
const Receiver: FC<()> = |cx, props|{
108+
const Receiver: Component<()> = |cx, props|{
109109
let title = use_signal(&cx, &TITLE);
110110
log::info!("This will only be called once!");
111111
rsx!(cx,
@@ -132,7 +132,7 @@ Dioxus automatically understands how to use your signals when mixed with iterato
132132

133133
```rust
134134
const DICT: AtomFamily<String, String> = |_| {};
135-
const List: FC<()> = |cx, props|{
135+
const List: Component<()> = |cx, props|{
136136
let dict = use_signal(&cx, &DICT);
137137
cx.render(rsx!(
138138
ul {

docs/guide/src/concepts/components.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ fn VoteButton(cx: Context, props: &VoteButtonProps) -> Element {
124124
cx.render(rsx!{
125125
div { class: "votebutton"
126126
div { class: "arrow up" }
127-
div { class: "score", "{props.score}"}
127+
div { class: "score", "{cx.props.score}"}
128128
div { class: "arrow down" }
129129
}
130130
})
@@ -147,7 +147,7 @@ struct TitleCardProps<'a> {
147147

148148
fn TitleCard(cx: Context, props: &TitleCardProps) -> Element {
149149
cx.render(rsx!{
150-
h1 { "{props.title}" }
150+
h1 { "{cx.props.title}" }
151151
})
152152
}
153153
```

docs/guide/src/concepts/conditional_rendering.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ fn App(cx: Context, props: &())-> Element {
8383

8484
This syntax even enables us to write a one-line component:
8585
```rust
86-
static App: FC<()> = |cx, props| rsx!(cx, "hello world!");
86+
static App: Component<()> = |cx, props| rsx!(cx, "hello world!");
8787
```
8888

8989
Alternatively, for match statements, we can just return the builder itself and pass it into a final, single call to `cx.render`:

docs/guide/src/concepts/exporting_components.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Let's say our app looks something like this:
2222
use dioxus::prelude::*;
2323

2424
fn main() {
25-
dioxus::desktop::launch(App, |c| c);
25+
dioxus::desktop::launch(App);
2626
}
2727

2828
fn App((cx, props): Component<()>) -> Element {}
@@ -87,7 +87,7 @@ In our `main.rs`, we'll want to declare the `post` module so we can access our `
8787
use dioxus::prelude::*;
8888

8989
fn main() {
90-
dioxus::desktop::launch(App, |c| c);
90+
dioxus::desktop::launch(App);
9191
}
9292

9393
mod post;
@@ -186,7 +186,7 @@ Ultimately, including and exporting components is governed by Rust's module syst
186186
use dioxus::prelude::*;
187187

188188
fn main() {
189-
dioxus::desktop::launch(App, |c| c);
189+
dioxus::desktop::launch(App);
190190
}
191191

192192
mod post;

docs/guide/src/concepts/interactivity.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ The most common hook you'll use for storing state is `use_state`. `use_state` pr
6464

6565
```rust
6666
fn App(cx: Context, props: &())-> Element {
67-
let post = use_state(cx, || {
67+
let post = use_state(&cx, || {
6868
PostData {
6969
id: Uuid::new_v4(),
7070
score: 10,
@@ -112,7 +112,7 @@ For example, let's say we provide a button to generate a new post. Whenever the
112112

113113
```rust
114114
fn App(cx: Context, props: &())-> Element {
115-
let post = use_state(cx, || PostData::new());
115+
let post = use_state(&cx, || PostData::new());
116116

117117
cx.render(rsx!{
118118
button {
@@ -135,7 +135,7 @@ We can use tasks in our components to build a tiny stopwatch that ticks every se
135135
```rust
136136

137137
fn App(cx: Context, props: &())-> Element {
138-
let mut sec_elapsed = use_state(cx, || 0);
138+
let mut sec_elapsed = use_state(&cx, || 0);
139139

140140
cx.spawn_task(async move {
141141
TimeoutFuture::from_ms(1000).await;

0 commit comments

Comments
 (0)