Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

233
Visualizações
Blazor calling JSInterop script that builds UI fails to render correctly

I'm trying to get this to work as per Microsoft's documentation.

The below script code works perfectly in an existing React app and I'm trying to port the app to Blazor. The script loads and inits - and I can see the Iframe being correctly loaded into the browser DOM. However the script (Apple's mapkit.js script) errors out with Attempted to assign to readonly property in the migrateStateTo function, trying to set t.tint = this.node.tint.

MapkitHelper.js

import "https://cdn.apple-mapkit.com/mk/5.x.x/mapkit.js";

export function initialiseMapkit(token, element) {
  // this call seems to work
  mapkit.init({
    authorizationCallback: function(done) {
      done(token)
    }  
  })
  // from here on things seem to go south no matter what I do
  var map = new mapkit.Map(element)
}

MapkitRenderer.razor

@implements IAsyncDisposable
@inject IJSRuntime JS

<div @ref="mapkitElement"></div>

@code {
  public string? token = Environment.GetEnvironmentVariable("MAPKIT_JS_TOKEN");

  private ElementReference mapkitElement;
  private IJSObjectReference? mapModule;

  protected override async Task OnAfterRenderAsync(bool firstRender) {
    if (firstRender) {
      mapModule = await JS.InvokeAsync<IJSObjectReference>("import", "./MapkitHelper.js");
      await mapModule.InvokeVoidAsync("initialiseMapkit", token, mapkitElement);
    }
  }

  async ValueTask IAsyncDisposable.DisposeAsync() {
    if (mapModule is not null) {
      await mapModule.DisposeAsync();
    }
  }
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I encountered this problem because I loaded mapkit.js as a module.

import "https://cdn.apple-mapkit.com/mk/5.x.x/mapkit.js";

Loading mapkit.js as a module results in an exception because mapkit.js is not compatible with JavaScript's strict mode. You must instead load mapkit.js in sloppy mode.

<script src=""https://cdn.apple-mapkit.com/mk/5.x.x/mapkit.js"></script>

Based on https://developer.apple.com/forums/thread/706389

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda