Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a 0.6 migration guide #327

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs-src/0.5/src/migration/fermi.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ fn app(cx: Scope) -> Element {

Dioxus 0.5:
```rust
{{#include src/doc_examples/migration_fermi.rs:intro}}
{{#include src/doc_examples/untested_05/migration_fermi.rs:intro}}
```

## Memos

Dioxus 0.5 introduces global memos which can be used to store computed values globally.

```rust
{{#include src/doc_examples/migration_fermi.rs:memos}}
{{#include src/doc_examples/untested_05/migration_fermi.rs:memos}}
```
4 changes: 2 additions & 2 deletions docs-src/0.5/src/migration/hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fn MyComponent(cx: Scope) -> Element {
Dioxus 0.5:

```rust
{{#include src/doc_examples/migration_hooks.rs:use_resource}}
{{#include src/doc_examples/untested_05/migration_hooks.rs:use_resource}}
```

### Dependencies
Expand All @@ -55,5 +55,5 @@ fn HasDependencies(cx: Scope) -> Element {
Dioxus 0.5:

```rust
{{#include src/doc_examples/migration_hooks.rs:dependencies}}
{{#include src/doc_examples/untested_05/migration_hooks.rs:dependencies}}
```
10 changes: 5 additions & 5 deletions docs-src/0.5/src/migration/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fn app(cx: Scope) -> Element {
```
Dioxus 0.5:
```rust
{{#include src/doc_examples/migration.rs:scope}}
{{#include src/doc_examples/untested_05/migration.rs:scope}}
```

### Props
Expand Down Expand Up @@ -73,7 +73,7 @@ fn ManualPropsComponent(cx: Scope<ManualProps>) -> Element {

Dioxus 0.5:
```rust
{{#include src/doc_examples/migration.rs:props}}
{{#include src/doc_examples/untested_05/migration.rs:props}}
```

You can read more about the new props API in the [Props Migration](props.md) guide.
Expand All @@ -88,7 +88,7 @@ use_future((dependency1, dependency2,), move |(dependency1, dependency2,)| async
```
Dioxus 0.5:
```rust
{{#include src/doc_examples/migration.rs:futures}}
{{#include src/doc_examples/untested_05/migration.rs:futures}}
```

Read more about the `use_resource` hook in the [Hook Migration](hooks.md) guide.
Expand Down Expand Up @@ -124,7 +124,7 @@ cx.render(rsx!{
Dioxus 0.5:

```rust
{{#include src/doc_examples/migration.rs:state}}
{{#include src/doc_examples/untested_05/migration.rs:state}}
```

Read more about the `use_signal` hook in the [State Migration](state.md) guide.
Expand Down Expand Up @@ -188,7 +188,7 @@ fn ChildWithRef(cx: Scope) -> Element {

Dioxus 0.5:
```rust
{{#include src/doc_examples/migration.rs:fermi}}
{{#include src/doc_examples/untested_05/migration.rs:fermi}}
```

You can read more about global signals in the [Fermi migration guide](fermi.md).
8 changes: 4 additions & 4 deletions docs-src/0.5/src/migration/props.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ fn Comp(cx: Scope, name: String) -> Element {
```
Dioxus 0.5:
```rust
{{#include src/doc_examples/migration_props.rs:owned_props}}
{{#include src/doc_examples/untested_05/migration_props.rs:owned_props}}
```

Because props are cloned every render, making props Copy is recommended. You can easily make a field Copy by accepting `ReadOnlySignal<T>` instead of `T` in the props struct:

```rust
{{#include src/doc_examples/migration_props.rs:copy_props}}
{{#include src/doc_examples/untested_05/migration_props.rs:copy_props}}
```

## Borrowed Props
Expand Down Expand Up @@ -54,7 +54,7 @@ fn BorrowedComp<'a>(cx: Scope<'a>, name: &'a str) -> Element<'a> {

Dioxus 0.5:
```rust
{{#include src/doc_examples/migration_props.rs:borrowed_props}}
{{#include src/doc_examples/untested_05/migration_props.rs:borrowed_props}}
```

## Manual Props
Expand All @@ -78,5 +78,5 @@ fn ManualPropsComponent(cx: Scope<ManualProps>) -> Element {

Dioxus 0.5:
```rust
{{#include src/doc_examples/migration_props.rs:manual_props}}
{{#include src/doc_examples/untested_05/migration_props.rs:manual_props}}
```
8 changes: 4 additions & 4 deletions docs-src/0.5/src/migration/state.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fn Child(cx: Scope, state: UseState<i32>) -> Element {
Parent would re-render every time the state changed even though only the child component was using the state. With the new `use_signal` hook, the parent would only re-render if the state was changed within the parent component:

```rust
{{#include src/doc_examples/migration_state.rs:use_signal}}
{{#include src/doc_examples/untested_05/migration_state.rs:use_signal}}
```
Only the child component will re-render when the state changes because only the child component is reading the state.

Expand All @@ -34,7 +34,7 @@ Only the child component will re-render when the state changes because only the
The `use_shared_state_provider` and `use_shared_state` hooks have been replaced with using the `use_context_provider` and `use_context` hooks with a `Signal`:

```rust
{{#include src/doc_examples/migration_state.rs:context_signals}}
{{#include src/doc_examples/untested_05/migration_state.rs:context_signals}}
```

Signals are smart enough to handle subscribing to the right scopes without a special shared state hook.
Expand All @@ -47,7 +47,7 @@ Some state hooks including `use_shared_state` and `use_ref` hooks had a function
Instead, you can use the `peek` function to read the current value of a signal without subscribing to it. This inverts the subscription model so that you can opt out of subscribing to a signal instead of opting all subscribers out of updates:

```rust
{{#include src/doc_examples/migration_state.rs:peek}}
{{#include src/doc_examples/untested_05/migration_state.rs:peek}}
```

`peek` gives you more fine-grained control over when you want to subscribe to a signal. This can be useful for performance optimizations and for updating state without re-rendering components.
Expand All @@ -57,7 +57,7 @@ Instead, you can use the `peek` function to read the current value of a signal w
In `0.4`, the fermi crate provided a separate global state API called atoms. In `0.5`, the `Signal` type has been extended to provide a global state API. You can use the `Signal::global` function to create a global signal:

```rust
{{#include src/doc_examples/migration_state.rs:global_signals}}
{{#include src/doc_examples/untested_05/migration_state.rs:global_signals}}
```

You can read more about global signals in the [Fermi migration guide](fermi.md).
6 changes: 1 addition & 5 deletions docs-src/0.6/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,7 @@
- [Examples](cookbook/examples.md)
- [Tailwind](cookbook/tailwind.md)
- [Optimizing](cookbook/optimizing.md)
- [Migration for 0.5](migration/index.md)
- [Hooks](migration/hooks.md)
- [State](migration/state.md)
- [Fermi](migration/fermi.md)
- [Props](migration/props.md)
- [Migration for 0.6](migration/index.md)

<!-- - [Static Generation](router/reference/static-generation.md) -->
<!-- - [CLI in Depth](router/reference/cli-in-depth.md)
Expand Down
42 changes: 0 additions & 42 deletions docs-src/0.6/src/migration/fermi.md

This file was deleted.

59 changes: 0 additions & 59 deletions docs-src/0.6/src/migration/hooks.md

This file was deleted.

Loading
Loading