Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

167
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda