Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

How to structure jsx between /client/ /server/ and /both/ subdirectories #65

Open
gb96 opened this issue Apr 16, 2015 · 2 comments
Open

Comments

@gb96
Copy link

gb96 commented Apr 16, 2015

Meteor restricts any js located below /client/ to client-side, and js located below /server/ to server-side. Everything else is available on both client and server side (some like to put stuff under /both/ or /model/ etc for clarity).

Currently there is only one react-meteor example and it has all the js code within a single JSX file which includes some if (Meteor.isServer) {} and if (Meteor.isClient) {} blocks. Can developers split these blocks into separate js files (looks like pure js, so no JSX required) located under /server/ and /client/ respectively? Does the rest of the leaderboard example JSX code have to be in the "both" category or can some of it be limited to client/server?

@ahoereth
Copy link

ahoereth commented May 5, 2015

Example works fine if you split the leaderboard.jsx file into three files, e.g.:

Leaderboard folder structure just follows the official example's folder structure.

@jedwards1211
Copy link

As I've been saying in other issues, use Webpack to build your frontend into JS bundles that go in a client folder.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants