@@ -66,21 +66,23 @@ private static IReactEnvironment Environment
6666 /// <param name="props">Props to initialise the component with</param>
6767 /// <param name="htmlTag">HTML tag to wrap the component in. Defaults to <div></param>
6868 /// <param name="containerId">ID to use for the container HTML tag. Defaults to an auto-generated ID</param>
69+ /// <param name="clientOnly">Skip rendering server-side and only output client-side initialisation code. Defaults to false</param>
6970 /// <returns>The component's HTML</returns>
7071 public static IHtmlString React < T > (
7172 this IHtmlHelper htmlHelper ,
7273 string componentName ,
7374 T props ,
7475 string htmlTag = null ,
75- string containerId = null
76+ string containerId = null ,
77+ bool clientOnly = false
7678 )
7779 {
7880 var reactComponent = Environment . CreateComponent ( componentName , props , containerId ) ;
7981 if ( ! string . IsNullOrEmpty ( htmlTag ) )
8082 {
8183 reactComponent . ContainerTag = htmlTag ;
8284 }
83- var result = reactComponent . RenderHtml ( ) ;
85+ var result = reactComponent . RenderHtml ( clientOnly ) ;
8486 return new HtmlString ( result ) ;
8587 }
8688
@@ -95,21 +97,23 @@ public static IHtmlString React<T>(
9597 /// <param name="props">Props to initialise the component with</param>
9698 /// <param name="htmlTag">HTML tag to wrap the component in. Defaults to <div></param>
9799 /// <param name="containerId">ID to use for the container HTML tag. Defaults to an auto-generated ID</param>
100+ /// <param name="clientOnly">Skip rendering server-side and only output client-side initialisation code. Defaults to false</param>
98101 /// <returns>The component's HTML</returns>
99102 public static IHtmlString ReactWithInit < T > (
100103 this IHtmlHelper htmlHelper ,
101104 string componentName ,
102105 T props ,
103106 string htmlTag = null ,
104- string containerId = null
107+ string containerId = null ,
108+ bool clientOnly = false
105109 )
106110 {
107111 var reactComponent = Environment . CreateComponent ( componentName , props , containerId ) ;
108112 if ( ! string . IsNullOrEmpty ( htmlTag ) )
109113 {
110114 reactComponent . ContainerTag = htmlTag ;
111115 }
112- var html = reactComponent . RenderHtml ( ) ;
116+ var html = reactComponent . RenderHtml ( clientOnly ) ;
113117 var script = new TagBuilder ( "script" )
114118 {
115119 InnerHtml = reactComponent . RenderJavaScript ( )
@@ -132,4 +136,4 @@ public static IHtmlString ReactInitJavaScript(this IHtmlHelper htmlHelper)
132136 return new HtmlString ( tag . ToString ( ) ) ;
133137 }
134138 }
135- }
139+ }
0 commit comments