#Why render.js doesnt work?

1 messages · Page 1 of 1 (latest)

frigid notch
#

Hello
When the paths are:

main.js
preload.js
renderer.js
index.html

Everything work fine
But when I changed it to:

main.js
preload.js
scripts
    renderer.js
index.html

render.js doesnt work (In index.html I changed from <script src="./renderer.js"></script> to <script src="./scripts/renderer.js"></script>)
Thanks for answers

burnt ruin
#

name is incorrect

frigid notch
burnt ruin
#

you getting 404 error?

frigid notch
#

Oh. I tested It now, render.js works. preload.js may be work not correct

frigid notch
# frigid notch Oh. I tested It now, render.js works. preload.js may be work not correct

for example, the code in preload.js:

const {contextBridge, ipcRenderer} = require('electron');
const {readFile, writeFile} = require('fs/promises');

contextBridge.exposeInMainWorld('settingsAPI', {
  getSettings: () => readFile('settings.json').then(JSON.parse),
  saveSettings: (value) => writeFile('settings.json', JSON.stringify(value)),
});

renderer.js:

const saveSettings = async () => {
  console.log(globalThis.settingsAPI.getSettings())
  globalThis.settingsAPI.saveSettings({language: 'EN', email: '', password: ''})
};
console.log('test')

Before the change, I had globalThis.settingsAPI.getSettings() and test in output, but after the change I have only test

burnt ruin
#

then this is not only you change

#

have you call saveSettings ?

frigid notch
burnt ruin
#

think?

frigid notch
#

yes

#

Just dont understand why there is no output. If I move preload.js in scripts, and change the path in main.js, then nothing changes, still no output

burnt ruin
#

with given code i cant say

frigid notch
#

Thanks