-
Notifications
You must be signed in to change notification settings - Fork 113
How to use separate .JSX files for ReactJS components? #55
Comments
I found some late night typo's in my code, but still can't get this working. Changed to: Also tried: |
It's far simpler (not necessarily in a good way) than using require(). There is no require() in the front side of meteor, all files in the client folder are loaded in as globals in alphabetical order with some directory nesting. To use a sepereate .jsx file, just take off the Component.jsx Component = ReactMeteor.createClass({
render: function(){
return(
<Player name="whatever" />
)
}
}) Player.jsx Player = ReactMeteor.createClass({
render: function(){
return(
<div>{this.props.name}</div>
)
}
}) |
For the leaderboard example I had to do this in Another work around I going was to put the React client in a directory outside of the Meteor project, run Browserify on the JSX, copying the resulting output file into the Meteor project directory. Just don't include btw: I don't mind not using require, it's needing to remove Put this in
|
@tehfailsafe thanks for this 👍 |
My solution was to use Webpack to build my frontend. |
@tehfailsafe |
I used to use .jsx extensions for files containing JSX. But eventually it seemed like pointless extra effort and I renamed them all to .js |
I can't figure out how to use separate .jsx files for ReactJS components. I tried just putting the component in it's own file.
Then tried using
var Player = require('./player');
withmodule.exports = "Player";
in player.jsx along withmkdir client
,cd client
,npm install require
, with the player.jsx file in the/client
.Then tried renaming to player.js.
Can't figure this out.
The text was updated successfully, but these errors were encountered: