Toni Michel Caubet
Toni Michel Caubet

Reputation: 20163

Uncaught ReferenceError: exports is not defined using reactjs

I'm trying to make my first attempt with react.js, I donwloaded the sample project from here

And created a scripts.js like so:

import React from 'react';

class App extends React.Component {
    constructor () {
        super ();
        this.state = {
            text: 'Default text'
        }
    }

    update (e) {
        this.setState ({text: e.target.value});
    }

    render () {
        return (
            <div>
                <input onChange={this.update.bind(this)} type="text" />
                <div>{this.state.text}</div>
            </div>
        )
    }
}

export default App;

But fires this error

enter image description here

Any idea what i'm doing wrong?

BTW, this is how the .html looks ( screenshot because it uses url-shorteners )

enter image description here

Upvotes: 0

Views: 4558

Answers (1)

Nikolai Tenev
Nikolai Tenev

Reputation: 476

I'm not 100% certain about this, but it looks like you are using ECMA6/7 features in an environment that does not support them.

For a quick and easy project setup, that supports ECMA6/7 you can use create-react-app package

Upvotes: 2

Related Questions