Datsik
Datsik

Reputation: 14824

How to import nested objects in ES6

Simple question, I'm trying to use electron and I need to get the remote object on the client.

Doing

const {BrowserWindow} = require('electron').remote; // Works

But

import {BrowserWindow} from 'electron/remote' // Does not work

New to ES6 classes just unsure why this is not working. Thanks.

Upvotes: 10

Views: 11934

Answers (2)

Richard Casetta
Richard Casetta

Reputation: 446

You can only import from modules. electron/remote is not a module, but remote is part of the module electron, so you can write :

import remote from "electron";

And then you can do :

const {BrowserWindow} = remote;

But your first code works fine ! You can read more on import statement here

Hope this helps

Upvotes: 7

Horia Coman
Horia Coman

Reputation: 8781

I think you're supposed to use it like this:

import {remote} from 'electron'
// do something with remote.BrowserWindow

Upvotes: 0

Related Questions