react-rails icon indicating copy to clipboard operation
react-rails copied to clipboard

JSX files not compiled in development mode

Open hackley opened this issue 11 years ago • 6 comments

After installing the gem (0.12.0.0), I am able to precompile my jsx files, but they are not compiled when I visit a page that requests a jsx file via javascript_include_tag. Should the JSX files be compiling on the fly in development mode?

Thanks!

hackley avatar Feb 11 '15 22:02 hackley

They should compile on the fly. Did you add .jsx to the filename? For example, my_component.js.jsx.

rmosolgo avatar Feb 11 '15 23:02 rmosolgo

Yes, the file is named member_list.js.jsx

In my view I have the following:

<%= javascript_include_tag('react') %>
<%= javascript_include_tag('react_components/member_list') %>

And at the top of my JSX file is

/** @jsx React.DOM */

I'm getting a console error: GET http://localhost:3000/assets/react_components/member_list.js 404 (Not Found)

When I update the js include tag to:

<%= javascript_include_tag('react_components/member_list.js.jsx') %>

I get this console error: Uncaught SyntaxError: Unexpected token < (because it isn't compiled)

hackley avatar Feb 12 '15 16:02 hackley

That's nuts ... and you did restart your development server since installing the gem?

rmosolgo avatar Feb 12 '15 16:02 rmosolgo

Yeah, just did once more to verify, but no change.

hackley avatar Feb 12 '15 16:02 hackley

I got it working! I think it was some combination of a caching issue and JS load order... super weird, though. I'll reply here if I can unearth more details.

Thanks for the help!

hackley avatar Feb 12 '15 17:02 hackley

I had the same issue. Components were not precompiled. I had to stop rails, delete the tmp folder, and restart.

coorasse avatar Sep 16 '16 14:09 coorasse