Skip to content

Commit 3a8eb4d

Browse files
committed
Switch the order of server and client-side console.log calls
Server-side calls should show up before their client-side counterparts, as server-side rendering runs first.
1 parent b11f198 commit 3a8eb4d

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/React.Core/ReactEnvironment.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,15 +290,16 @@ public virtual IReactComponent CreateComponent<T>(string componentName, T props,
290290
public virtual string GetInitJavaScript()
291291
{
292292
var fullScript = new StringBuilder();
293+
294+
// Propagate any server-side console.log calls to corresponding client-side calls.
295+
var consoleCalls = Execute<string>("console.getCalls()");
296+
fullScript.Append(consoleCalls);
297+
293298
foreach (var component in _components)
294299
{
295300
fullScript.Append(component.RenderJavaScript());
296301
fullScript.AppendLine(";");
297302
}
298-
299-
// Also propagate any server-side console.log calls to corresponding client-side calls.
300-
var consoleCalls = Execute<string>("console.getCalls()");
301-
fullScript.Append(consoleCalls);
302303

303304
return fullScript.ToString();
304305
}

0 commit comments

Comments
 (0)