Skip to content

Commit

Permalink
Fixed hydration condition based on options
Browse files Browse the repository at this point in the history
  • Loading branch information
AyronK committed Nov 23, 2023
1 parent 4ca4865 commit 0ede93a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Forte.Web.React/React/ReactService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ public async Task<string> 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($"<div id=\"{component.ContainerId}\">").ConfigureAwait(false);
Expand All @@ -132,7 +133,6 @@ public async Task RenderAsync(TextWriter writer, string componentName, object? p
return;
}

options ??= new RenderOptions();
var streamingOptions = new
{
options.EnableStreaming,
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit 0ede93a

Please sign in to comment.