diff --git a/Forte.Web.React/Forte.Web.React.csproj b/Forte.Web.React/Forte.Web.React.csproj index ce57eb6..e101bcd 100644 --- a/Forte.Web.React/Forte.Web.React.csproj +++ b/Forte.Web.React/Forte.Web.React.csproj @@ -6,8 +6,8 @@ enable latest true - 1.0.1.0 - 1.0.1.0 + 1.0.2.0 + 1.0.2.0 diff --git a/Forte.Web.React/React/ReactService.cs b/Forte.Web.React/React/ReactService.cs index b9b4276..d6a9c24 100644 --- a/Forte.Web.React/React/ReactService.cs +++ b/Forte.Web.React/React/ReactService.cs @@ -118,16 +118,15 @@ public async Task RenderToStringAsync(string componentName, object? prop return WrapRenderedStringComponent(result, component); } - public async Task RenderAsync(TextWriter writer, string componentName, object? props = null, - RenderOptions? options = null) + public async Task RenderAsync(TextWriter writer, string componentName, object? props = null, RenderOptions? options = null) { options ??= new RenderOptions(); - var component = new Component(componentName, props, options.ServerOnly ? RenderingMode.Server : RenderingMode.ClientAndServer); + var component = new Component(componentName, props, options.RenderingMode); Components.Add(component); await writer.WriteAsync($"
").ConfigureAwait(false); - if (_config.IsServerSideDisabled) + if (_config.IsServerSideDisabled || component.RenderingMode == RenderingMode.Client) { await writer.WriteAsync("
").ConfigureAwait(false); return; @@ -136,7 +135,7 @@ public async Task RenderAsync(TextWriter writer, string componentName, object? p var streamingOptions = new { options.EnableStreaming, - options.ServerOnly, + ServerOnly = component.RenderingMode == RenderingMode.Server, IdentifierPrefix = _config.UseIdentifierPrefix ? component.ContainerId : null, }; @@ -257,12 +256,20 @@ private string GetIdentifierPrefix(Component component) => _config.UseIdentifier public class RenderOptions { - public RenderOptions(bool serverOnly = false, bool enableStreaming = true) + public RenderOptions() : this(RenderingMode.ClientAndServer, true) { - ServerOnly = serverOnly; + } + + public RenderOptions(bool serverOnly, bool enableStreaming = true) : this(serverOnly ? RenderingMode.Server : RenderingMode.ClientAndServer, enableStreaming) + { + } + + public RenderOptions(RenderingMode renderingMode, bool enableStreaming = true) + { + RenderingMode = renderingMode; EnableStreaming = enableStreaming; } - public bool ServerOnly { get; } + public RenderingMode RenderingMode { get; } public bool EnableStreaming { get; } }