Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor deprecated BrowserView API example #1648

Open
aadcg opened this issue Oct 30, 2024 · 2 comments
Open

Refactor deprecated BrowserView API example #1648

aadcg opened this issue Oct 30, 2024 · 2 comments

Comments

@aadcg
Copy link

aadcg commented Oct 30, 2024

Note that under "Show Me" -> "Electron APIs" -> "BrowserView", the example displayed still uses the deprecated API.

@Santhoshmani1
Copy link
Contributor

Santhoshmani1 commented Dec 17, 2024

The latest documentation suggests to use the WebContentsView Class to display the web contents.

The BrowserView class is deprecated, and replaced by the new WebContentsView class.
https://www.electronjs.org/docs/latest/api/browser-view

We should remove the browserview/main.js and should add a new file for the WebContentsView Class.

Here is the code provided under the WebContentsView class that we can add under the show-me examples.

const { BaseWindow, WebContentsView } = require('electron')
const win = new BaseWindow({ width: 800, height: 400 })

const view1 = new WebContentsView()
win.contentView.addChildView(view1)
view1.webContents.loadURL('https://electronjs.org')
view1.setBounds({ x: 0, y: 0, width: 400, height: 400 })

const view2 = new WebContentsView()
win.contentView.addChildView(view2)
view2.webContents.loadURL('https://github.com/electron/electron')
view2.setBounds({ x: 400, y: 0, width: 400, height: 400 })

@Santhoshmani1
Copy link
Contributor

Should we remove the BrowserView Class example from the Show-me section or should we leave it as it is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants