Skip to content

Commit e72767d

Browse files
committed
fix: feature soundness
1 parent 0d8aa3b commit e72767d

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

packages/yew/src/lazy.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
use std::future::Future;
77

8-
use crate::html::{Scope, Scoped};
8+
use crate::html::Scope;
99
use crate::suspense::Suspension;
1010
use crate::{BaseComponent, Context, HtmlResult};
1111

@@ -104,7 +104,17 @@ impl<C: LazyComponent> BaseComponent for Lazy<C> {
104104
type Properties = <C::Underlying as BaseComponent>::Properties;
105105

106106
fn create(ctx: &Context<Self>) -> Self {
107-
let inner_scope = Scope::new(Some(ctx.link().to_any()));
107+
#[cfg(not(any(feature = "ssr", feature = "csr")))]
108+
{
109+
let _ = ctx;
110+
todo!("Component shouldn't render without any rendering mode enabled");
111+
}
112+
#[allow(unreachable_code)]
113+
let inner_scope;
114+
#[cfg(any(feature = "ssr", feature = "csr"))]
115+
{
116+
inner_scope = Scope::new(Some(ctx.link().clone().into()));
117+
}
108118
let creation_ctx = ctx.narrow_scope(&inner_scope);
109119

110120
let link = ctx.link().clone();

0 commit comments

Comments
 (0)