in src/React.AspNet/HtmlHelperExtensions.cs [115:153]
public static IHtmlString ReactWithInit<T>(
this IHtmlHelper htmlHelper,
string componentName,
T props,
string htmlTag = null,
string containerId = null,
bool clientOnly = false,
bool serverOnly = false,
string containerClass = null,
Action<Exception, string, string> exceptionHandler = null,
IRenderFunctions renderFunctions = null
)
{
try
{
var reactComponent = Environment.CreateComponent(componentName, props, containerId, clientOnly);
if (!string.IsNullOrEmpty(htmlTag))
{
reactComponent.ContainerTag = htmlTag;
}
if (!string.IsNullOrEmpty(containerClass))
{
reactComponent.ContainerClass = containerClass;
}
return RenderToString(writer =>
{
reactComponent.RenderHtml(writer, clientOnly, serverOnly, exceptionHandler: exceptionHandler, renderFunctions);
writer.WriteLine();
WriteScriptTag(writer, bodyWriter => reactComponent.RenderJavaScript(bodyWriter, waitForDOMContentLoad: true));
});
}
finally
{
Environment.ReturnEngineToPool();
}
}