JavaScript interop calls cannot be issued at this time

See original GitHub issue

It is forbidden to use JSRuntime during pre-rendering.

[Inject]
protected IJSRuntime JS { get; set; }

protected override void OnAfterRender()
{
   JS.InvokeAsync<bool>("paceDone");
   base.OnAfterRender();
}
System.InvalidOperationException: "JavaScript interop calls cannot be issued at this time. This is because the component is being prerendered and the page has not yet loaded in the browser or because the circuit is currently disconnected. Components must wrap any JavaScript interop calls in conditional logic to ensure those interop calls are not attempted during prerendering or while the client is disconnected."

How do I know that JSRuntime is unavailable? There are some solutions to this problem besides resource-intensive try { } ?

Blazor 0.10

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ghostcommented, Apr 21, 2019

Ideally, a solution to disable pre-rendering would help, so that JSRuntime could be used anywhere, including OnInit without additional switches in OnAfterRenderAsync.

0reactions
ghostcommented, Apr 21, 2019

I solved the problem by disabling the preliminary rendering https://github.com/aspnet/AspNetCore/pull/8911 (I do not need it for the current project)

Read more comments on GitHub >

github_iconTop Results From Across the Web

asp.net core - JavaScript interop Error when calling ...
JavaScript interop calls cannot be issued at this time. This is because the component is being statically rendererd.
Read more >
JavaScript interop calls cannot be issued at this time when ...
I work on blazor web app with .net core 7 . I get error when try to pass user name from login page...
Read more >
Calling Javascript interop from inside OnAfterRenderAsync ...
JavaScript interop calls cannot be issued at this time. This is because the component is being statically rendered.
Read more >
Identifying what is causing interop errors : r/Blazor
JSDisconnectedException: JavaScript interop calls cannot be issued at this time. This is because the circuit has disconnected and is being ...
Read more >
Pros and Cons of Using JavaScript Interop in Blazor
The JavaScript interop call may fail due to a network issue and low bandwidth network in a server app. By default, it takes...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found