JavaScript interop calls cannot be issued at this time
See original GitHub issueIt 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:
- Created 4 years ago
- Comments:9 (2 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ideally, a solution to disable pre-rendering would help, so that JSRuntime could be used anywhere, including OnInit without additional switches in OnAfterRenderAsync.
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)