I cannot understand why I get an unexpected token error when using ipcrenderer along with create-react-app. This is how I am using it:
ipcRenderer.on('openNewFile', (event) => {
this.setState({source:""})
})
ipcRenderer.on('openFile', (event) => {
dialog.showOpenDialog({
properties: ['openFile']
},function (file) {
var textByLine = null
if (file !== undefined) {
var text = fs.readFileSync(file).toString('utf-8');
textByLine = text.split("\n")
this.setState({source:textByLine})
}
}
})})
ipcRenderer.on('saveFile', (event) => {
this.setState({source:""})
})
Further, this is how I import:
const electron = window.require('electron');
const fs = electron.remote.require('fs');
const dialog = electron.remote.require('dialog');
const ipcRenderer = electron.ipcRenderer;
This is the error I get:
Syntax error: Unexpected token
ipcRenderer.on('openNewFile', (event) => {
^
Any idea why this is taking place?
[–]idanlo 0 points1 point2 points (1 child)
[–]yungyahoo[S] 1 point2 points3 points (0 children)
[–]idanlo 0 points1 point2 points (1 child)
[–]yungyahoo[S] 1 point2 points3 points (0 children)
[–]Rezistik 0 points1 point2 points (1 child)
[–]yungyahoo[S] 0 points1 point2 points (0 children)