question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

  • I have read the contribution documentation for this project.
  • I agree to follow the code of conduct that this project follows, as appropriate.
  • I have searched the issue tracker for an issue that matches the one I want to file, without success.

Please describe your issue: I have installed the electron-forge and want to use the react template, but when I create the project and then add arrow functions it gives me error in the console log

What does your config.forge data in package.json look like?

"config": {
    "forge": {
      "make_targets": {
        "win32": [
          "squirrel"
        ],
        "darwin": [
          "zip"
        ],
        "linux": [
          "deb",
          "rpm"
        ]
      },
      "electronPackagerConfig": {
        "packageManager": "yarn"
      },
      "electronWinstallerConfig": {
        "name": "electronreact"
      },
      "electronInstallerDebian": {},
      "electronInstallerRedhat": {},
      "github_repository": {
        "owner": "",
        "name": ""
      },
      "windowsStoreConfig": {
        "packageName": "",
        "name": "electronreact"
      }
    }
  },
"dependencies": {
    "electron-compile": "^6.4.3",
    "electron-devtools-installer": "^2.1.0",
    "electron-squirrel-startup": "^1.0.0",
    "react": "^15.4.1",
    "react-dom": "^15.4.1",
    "react-hot-loader": "^3.0.0-beta.6"
  },
  "devDependencies": {
    "babel-plugin-transform-async-to-generator": "^6.24.1",
    "babel-plugin-transform-es2015-classes": "^6.24.1",
    "babel-preset-env": "^1.7.0",
    "babel-preset-react": "^6.24.1",
    "electron-forge": "^5.2.2",
    "electron-prebuilt-compile": "2.0.7",
    "eslint": "^3",
    "eslint-config-airbnb": "^15",
    "eslint-plugin-import": "^2",
    "eslint-plugin-jsx-a11y": "^5",
    "eslint-plugin-react": "^7"
  }

Please provide either a failing minimal testcase (with a link to the code) or detailed steps to reproduce your problem. Using electron-forge init is a good starting point, if that is not the source of your problem.

  1. I run this command electron-forge init my-new-project --template=react

2.I open the src/app.jsx file

import React from 'react';

export default class App extends React.Component {
  render() {
    return (<div>
      <h2>Welcome to React!</h2>
    </div>);
  }
}

  1. I refactor and add a arrow function
import React, {Component} from 'react';

export default class App extends Component {
  constructor(){
    super();

    this.state = {

    }
  }

  handleClick= () => {
    console.log('button clicked');
    
  }
  render() {
    return (<div>
      <h2>Welcome to React!</h2>
      <button onClick={this.handleClick}>Click me</button>
    </div>);
  }
}

then I get this error in the console /src/app.jsx: Unexpected token (10:14) and if you count that is the arrow function.

This is my first electron project and I really want to try it out, but I want to use the es6/es7 features.

Thank you for all the help and keep up the good work.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
CyrusZeicommented, Sep 4, 2018

for anybody that is coming here for the class props this is how I solved it.

  1. npm install babel-core
  2. open .compilerc
  3. inside of the plugins array add "transform-class-properties" in both development and production

enjoy

1reaction
S-Mitterlehnercommented, Sep 20, 2018

Hi, this doesn’t work for me.

I created a new Project and add an arrow function like u. I also added the babel-core and the plugin, but it doesnt work

Does anyone have another solution ? Version is “^5.2.2” with react template

Can u please post your working package.json?

Read more comments on GitHub >

github_iconTop Results From Across the Web

ES67 Disinfectant, Cleaner, Sanitizer and Deodorizer
ES67 Disinfectant, Cleaner, Sanitizer and Deodorizer. Available in USA Only. FEATURES & BENEFITS: EPA Reg #1839-224-64900; Hospital grade disinfectant ...
Read more >
Samsung ES67 Digital Camera Memory Card 2 x 8GB ...
Samsung ES67 Digital Camera Memory Card 2 x 8GB Secure Digital High Capacity (SDHC) Memory Cards (2 Pack) ; Compatible Devices. Camera ;...
Read more >
ES67 | Samsung Support UK
ES67. Solutions & Tips, Download Manual, Contact Us. Samsung Support UK.
Read more >
ES67-5AFORD | ProRig | Transmission
Shop for ProRig's ES67-5AFORD | Transmission at Wheelco.com now! The one stop shop for all your heavy duty needs.
Read more >
Standard Ignition Idle Stop Solenoid - ES67 - Zoro Tools
Order Standard Ignition Idle Stop Solenoid - ES67, ES67 at Zoro.com. Great prices & free shipping on orders over $50 when you sign...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found