Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

165
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!