-
-
Notifications
You must be signed in to change notification settings - Fork 960
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix mounted event after initial hydration (#3480)
* trigger queued mounted events immediately after hydrating * add a playwright test to prevent regressions
- Loading branch information
Showing
8 changed files
with
76 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// @ts-check | ||
const { test, expect } = require("@playwright/test"); | ||
|
||
test("hydration", async ({ page }) => { | ||
await page.goto("http://localhost:7777"); | ||
|
||
// Expect the page to contain the pending text. | ||
const main = page.locator("#main"); | ||
await expect(main).toContainText("The mounted event was triggered."); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[package] | ||
name = "dioxus-playwright-fullstack-mounted-test" | ||
version = "0.1.0" | ||
edition = "2021" | ||
publish = false | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
dioxus = { workspace = true, features = ["fullstack"] } | ||
serde = "1.0.159" | ||
tokio = { workspace = true, features = ["full"], optional = true } | ||
|
||
[features] | ||
default = [] | ||
server = ["dioxus/server", "dep:tokio"] | ||
web = ["dioxus/web"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Regression test for https://github.com/DioxusLabs/dioxus/pull/3480 | ||
|
||
use dioxus::prelude::*; | ||
|
||
fn main() { | ||
dioxus::launch(App); | ||
} | ||
|
||
#[component] | ||
fn App() -> Element { | ||
let mut mounted = use_signal(|| false); | ||
|
||
rsx! { | ||
div { | ||
onmounted: move |_| { | ||
mounted.set(true); | ||
}, | ||
if mounted() { | ||
"The mounted event was triggered." | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters