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

172
Visualizações
Import dialog in preload.js returns undefined

I'm trying to understand how context isolation works in electron. I want to expose the dialog.showErrorBox function from the electron module to the renderer process. As i understand the following code in preload.js should be sufficient:

import {contextBridge, dialog} from 'electron'

contextBridge.exposeInMainWorld(
  'electron',
  {
      showErrorDialog: dialog.showErrorBox
  }

Then in the renderer process I should be able to call this function as

window.electron.showErrorDialog(string, string)

However when importing electron in preload.js it appears as if it has no property dialog so that the import statement above returns dialog = undefined.

I have a feeling this has more to do with which properties the electron module exposes in the preload.js more than context isolation. It looks to me like there are several APIs which could be useful to expose to the renderer but are unavailable in preload.js (e.g. dialog, inAppPurchase) how is one supposed to use these?

This is basically a duplicate of Requiring electron dialog from render process is undefined however the answers to that question are outdated as they use the remote API which is no longer part of electron.

about 4 years ago · Juan Pablo Isaza
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