From 0ede93a9944fbe3c920192ea7b6d7bcbf617bbc8 Mon Sep 17 00:00:00 2001 From: AyronK Date: Thu, 23 Nov 2023 09:57:30 +0100 Subject: [PATCH] Fixed hydration condition based on options --- Forte.Web.React/React/ReactService.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Forte.Web.React/React/ReactService.cs b/Forte.Web.React/React/ReactService.cs index 1a7036c..1609e51 100644 --- a/Forte.Web.React/React/ReactService.cs +++ b/Forte.Web.React/React/ReactService.cs @@ -121,7 +121,8 @@ public async Task RenderToStringAsync(string componentName, object? prop public async Task RenderAsync(TextWriter writer, string componentName, object? props = null, RenderOptions? options = null) { - var component = new Component(componentName, props); + options ??= new RenderOptions(); + var component = new Component(componentName, props, options.ServerOnly ? RenderingMode.Server : RenderingMode.ClientAndServer); Components.Add(component); await writer.WriteAsync($"
").ConfigureAwait(false); @@ -132,7 +133,6 @@ public async Task RenderAsync(TextWriter writer, string componentName, object? p return; } - options ??= new RenderOptions(); var streamingOptions = new { options.EnableStreaming, @@ -210,7 +210,7 @@ public string GetInitJavascript() private string GetInitJavascriptSource(Component c) { - var shouldHydrate = !_config.IsServerSideDisabled && c.RenderingMode.HasFlag(RenderingMode.Server); + var shouldHydrate = !_config.IsServerSideDisabled && c.RenderingMode == RenderingMode.ClientAndServer; return shouldHydrate ? Hydrate(c) : Render(c); }