DioxusLabs / DioxusLabs/dioxus

[Docs]: Update Docs for Proper `#[layout]` and `#[end_layout]` Macros Usage in Enums

Open
#3,211 4 comments 0 reactions 0 assignees View on GitHub
documentation router
Dominant language
Rust
Stars
39.1k
Forks
1.9k
Avg merge
4d 10h
Merged PRs (30d)
4

Description

Hiya ( ´ ω ` )ノ゙,

This is not a critical issue, but I’ve noticed a bug with layout and routes ordering when defining multiple layouts for different pages.

Here’s an example that works:

```rust
#[derive(Clone, Routable, Debug, PartialEq, Serialize, Deserialize)]
pub enum Route {
#[layout(HomeNavBar)]
#[route("/")]
Home {},
#[end_layout]

#[layout(LoginNavBar)]
#[route("/login")]
Login {},
#[end_layout]

#[route("/dashboard")]
Dashboard {},
}
```

However, if you reorder the routes like this:

```rust
#[derive(Clone, Routable, Debug, PartialEq, Serialize, Deserialize)]
pub enum Route {
#[layout(HomeNavBar)]
#[route("/")]
Home {},
#[end_layout]

#[route("/dashboard")] // Notice this route between the layouts
Dashboard {},

#[layout(LoginNavBar)]
#[route("/login")]
Login {},
#[end_layout]
}
```

The routing doesn’t work as expected.

Just wanted to raise this to your attention.

Best

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.