Merge pull request #1570 from ealmloff/clarify-web-gaurd-fullstack

Add error message when overlapping fullstack features are enabled
This commit is contained in:
Jonathan Kelley 2023-10-23 16:32:34 -04:00 committed by GitHub
commit 716130d025
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 2 deletions

View file

@ -121,8 +121,15 @@ impl<Props: Clone + serde::Serialize + serde::de::DeserializeOwned + Send + Sync
#[cfg(feature = "web")]
/// Launch the web application
pub fn launch_web(self) {
let cfg = self.web_cfg.hydrate(true);
dioxus_web::launch_with_props(self.component, get_root_props_from_document().unwrap(), cfg);
#[cfg(not(feature = "ssr"))]
{
let cfg = self.web_cfg.hydrate(true);
dioxus_web::launch_with_props(
self.component,
get_root_props_from_document().unwrap(),
cfg,
);
}
}
#[cfg(feature = "desktop")]

View file

@ -64,3 +64,10 @@ pub mod prelude {
pub use hooks::{server_cached::server_cached, server_future::use_server_future};
}
// Warn users about overlapping features
#[cfg(all(feature = "ssr", feature = "web"))]
compile_error!("The `ssr` feature (enabled by `warp`, `axum`, or `salvo`) and `web` feature are overlapping. Please choose one or the other.");
#[cfg(all(feature = "ssr", feature = "desktop"))]
compile_error!("The `ssr` feature (enabled by `warp`, `axum`, or `salvo`) and `desktop` feature are overlapping. Please choose one or the other.");