@@ -256,10 +256,15 @@ public virtual bool HasVariable(string name)
256256 /// <param name="componentName">Name of the component</param>
257257 /// <param name="props">Props to use</param>
258258 /// <param name="containerId">ID to use for the container HTML tag. Defaults to an auto-generated ID</param>
259+ /// <param name="clientOnly">True if server-side rendering will be bypassed. Defaults to false.</param>
259260 /// <returns>The component</returns>
260- public virtual IReactComponent CreateComponent < T > ( string componentName , T props , string containerId = null )
261+ public virtual IReactComponent CreateComponent < T > ( string componentName , T props , string containerId = null , bool clientOnly = false )
261262 {
262- EnsureUserScriptsLoaded ( ) ;
263+ if ( ! clientOnly )
264+ {
265+ EnsureUserScriptsLoaded ( ) ;
266+ }
267+
263268 var component = new ReactComponent ( this , _config , componentName , containerId )
264269 {
265270 Props = props
@@ -272,14 +277,18 @@ public virtual IReactComponent CreateComponent<T>(string componentName, T props,
272277 /// Renders the JavaScript required to initialise all components client-side. This will
273278 /// attach event handlers to the server-rendered HTML.
274279 /// </summary>
280+ /// <param name="clientOnly">True if server-side rendering will be bypassed. Defaults to false.</param>
275281 /// <returns>JavaScript for all components</returns>
276- public virtual string GetInitJavaScript ( )
282+ public virtual string GetInitJavaScript ( bool clientOnly = false )
277283 {
278284 var fullScript = new StringBuilder ( ) ;
279285
280286 // Propagate any server-side console.log calls to corresponding client-side calls.
281- var consoleCalls = Execute < string > ( "console.getCalls()" ) ;
282- fullScript . Append ( consoleCalls ) ;
287+ if ( ! clientOnly )
288+ {
289+ var consoleCalls = Execute < string > ( "console.getCalls()" ) ;
290+ fullScript . Append ( consoleCalls ) ;
291+ }
283292
284293 foreach ( var component in _components )
285294 {
0 commit comments