File tree 3 files changed +10
-15
lines changed
3 files changed +10
-15
lines changed Original file line number Diff line number Diff line change @@ -111,16 +111,9 @@ pub fn run_client<M: MutableStore, T: TranslationsManager>(
111
111
}
112
112
} ;
113
113
114
- // If we're using hydration, everything has to be done inside a hydration
115
- // context (because of all the custom view handling)
116
- #[ cfg( feature = "hydrate" ) ]
117
- {
118
- running = with_hydration_context ( || core ( ) ) ;
119
- }
120
- #[ cfg( not( feature = "hydrate" ) ) ]
121
- {
122
- running = core ( ) ;
123
- }
114
+ // NOTE: To anyone who ever thinks it might be a good idea to put this whole
115
+ // thing in a `with_hydration_cx()`, it's not, it's really not.
116
+ core ( ) ;
124
117
} ) ;
125
118
126
119
dispatch_loaded ( running, false ) ;
Original file line number Diff line number Diff line change @@ -416,9 +416,6 @@ impl Reactor<BrowserNodeType> {
416
416
// This template is reactive, and will be updated as necessary
417
417
view! { cx,
418
418
( * self . current_view. get( ) )
419
- // BUG: Without this, any page that renders only one top-level node will lead to a hydration
420
- // error. Pending input from Sycamore...
421
- div { }
422
419
}
423
420
}
424
421
)
Original file line number Diff line number Diff line change @@ -14,7 +14,6 @@ use sycamore::{prelude::Scope, view::View};
14
14
///
15
15
/// **Warning:** if hydration is being used, it is expected that
16
16
/// the given view was created inside a `with_hydration_context()` closure.
17
- // TODO Make sure hydration will work when it's targeted at a blank canvas...
18
17
// XXX This is *highly* dependent on internal Sycamore implementation
19
18
// details! (TODO PR for `hydrate_to_with_scope` etc.)
20
19
#[ cfg( any( client, doc) ) ]
@@ -25,6 +24,8 @@ pub(crate) fn render_or_hydrate(
25
24
parent : web_sys:: Element ,
26
25
force_render : bool ,
27
26
) {
27
+ use sycamore:: utils:: hydrate:: { with_hydration_context, with_no_hydration_context} ;
28
+
28
29
#[ cfg( feature = "hydrate" ) ]
29
30
{
30
31
use sycamore:: web:: HydrateNode ;
@@ -50,7 +51,11 @@ pub(crate) fn render_or_hydrate(
50
51
insert (
51
52
cx,
52
53
& HydrateNode :: from_web_sys ( parent. into ( ) ) ,
53
- view, // We assume this was created in `with_hydration_context(..)`
54
+ if force_render {
55
+ with_no_hydration_context ( || view)
56
+ } else {
57
+ with_hydration_context ( || view)
58
+ } ,
54
59
if force_render {
55
60
None
56
61
} else {
You can’t perform that action at this time.
0 commit comments