Skip to content

[Bug]: JSinterop Exception #172

@mw-nfi

Description

@mw-nfi

Contact Details

No response

What happened?

I have a Blazor Server App and i would to like to use MudExTreeViewDefault. I use "keep it simple" the sample from the docs. But i received a exception...

How can i solve this problem?

==

<MudPaper Outlined Style="width:100% !important" Elevation="0" Class="ma-4">
	 <MudExTreeViewDefault @bind-SelectedNode="_selectedNode"
                                         @ref="component"
                                         Items="@Entries" Virtualize>
    </MudExTreeViewDefault>
</MudPaper>
@code {
    MudExTreeViewDefault<SampleTreeItem> component;
    private SampleTreeItem _selectedNode;
    public HashSet<SampleTreeItem> Entries { get; set; }

    protected override void OnInitialized()
    {
        Entries = SampleTreeStructure.GetItems();
    }


}

=====

I get this error message several times.

---> (Inner Exception #303) System.InvalidOperationException: JavaScript interop calls cannot be issued at this time. This is because the component is being statically rendered. When prerendering is enabled, JavaScript interop calls can only be performed during the OnAfterRenderAsync lifecycle method.
at Microsoft.AspNetCore.Components.Server.Circuits.RemoteJSRuntime.BeginInvokeJS(Int64 asyncHandle, String identifier, String argsJson, JSCallResultType resultType, Int64 targetInstanceId)
at Microsoft.JSInterop.JSRuntime.InvokeAsync[TValue](Int64 targetInstanceId, String identifier, CancellationToken cancellationToken, Object[] args)
at Microsoft.JSInterop.JSRuntime.InvokeAsync[TValue](Int64 targetInstanceId, String identifier, Object[] args)
at Microsoft.JSInterop.JSRuntimeExtensions.InvokeVoidAsync(IJSRuntime jsRuntime, String identifier, Object[] args)
at MudBlazor.Extensions.Components.MudExVirtualItem.DisposeAsync()
at Microsoft.AspNetCore.Components.RenderTree.Renderer.<>c__DisplayClass93_0.<g__HandleAsyncExceptions|0>d.MoveNext()<---

Expected Behavior

No Exception

Screenshots

No response

Reproduction link

No response

What application type are you referring to?

Please select an application type...

Custom Application Type

No response

MudBlazor.Extension Version

8.13.0

MudBlazor Version

8.13.0

What .net Version are you using?

.Net9

What browser are you using?

Edge

Sample Solution

No response

Pull Request

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions