Skip to content

[Bug] Unexpected token . at Microsoft.JSInterop.JSRuntime #581

Open
@JimGeersinga

Description

@JimGeersinga

Describe the bug
Unexpected token . in Blazor Webview I'm encountering a SyntaxError: Unexpected token . in my Blazor Webview application. The error details are as follows:

blazor.webview.js:1 Unexpected token .
SyntaxError: Unexpected token .
   at Microsoft.JSInterop.JSRuntime.<InvokeAsync>d__16`1[[Microsoft.JSInterop.IJSObjectReference, Microsoft.JSInterop, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].MoveNext()
   at Blazored.Modal.BlazoredModal.OnAfterRenderAsync(Boolean firstRender)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)
NotifyUnhandledException @ blazor.webview.js:1

To Reproduce
Steps to reproduce the behavior:

  1. Create new .NET MAUI Hybrid project
  2. Add Blazored.Modal to the project
  3. Add CascadingBlazoredModal around the router as mentioned in the documentation
  4. Start app in android emulator.

Expected behavior
App starts normally without any errors and I am able to show a modal after button click

Screenshots
image

Hosting Model (is this issue happening with a certain hosting model?):

  • MAUI Blazor Hybrid

Additional context

This is how my Routes.Razor looks like

@using Blazored.Modal

<CascadingBlazoredModal>
    <Router AppAssembly="@typeof(MauiProgram).Assembly">
        <Found Context="routeData">
            <RouteView RouteData="@routeData" DefaultLayout="@typeof(Layout.MainLayout)" />
            <FocusOnNavigate RouteData="@routeData" Selector="h1" />
        </Found>
    </Router>
</CascadingBlazoredModal>

I have tracked down the interop call location to this line in Blazored.Modal.

Looking at another (microsoft) component named QuickGrid I see that there is not really a difference.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't workingTriageIssue needs to be triaged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions