3

I am just getting started on a new project which I would like to write in ReactJS. I am trying to use Broserify to bundle everything so that I can have it in multiple js files.

However, when I try to bundle my react file (browserify main.js > bundle.js), I get this error: "Error: Parsing file /Users/Kathleen/Documents/Referral_Site/main.js: Unexpected token (3:4)"

main.js looks like this:

var Lander = require('./lander');
React.render(
    <Lander />,
    document.getElementById('content')
);

What's breaking the parser? Thanks in advance!

EDIT: also, I included react in the surrounding html like this:

<script src="http://fb.me/react-0.12.2.js"></script>

is there some way that I need to include it in main.js as well?

1 Answer 1

6

You must compile JSX to plain JS first, there is plugin for browserify.

https://www.npmjs.com/package/reactify

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.