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

Question about client-side/server-side rendering for clarity #39

Open
joshbedo opened this issue Jun 12, 2015 · 0 comments
Open

Question about client-side/server-side rendering for clarity #39

joshbedo opened this issue Jun 12, 2015 · 0 comments

Comments

@joshbedo
Copy link

So i setup react-engine as the view engine with krakenjs and everything has been working fine. My app.js file that bootstraps the client-side looks like the example below and i simply have a folder structure where views contains my server-side rendered pages like index, header, footer, single-listing and views also contains a directory called components which are bundled with browserify... so the problem i just noticed is the server-side and client-side files are being added into my bundle.js file. This was noticeable recently when i tried to do an $.ajax call inside components/AccountActions.jsx which i thought was only client-side.. and i received the error $ is not available or window is not available. I was wondering a few things.

  1. what is the purpose of the require('./views/**/*.jsx', {glob: true});
  2. does viewResolver handle paths for client-side views, server-side views or both?
  3. what is a good way to ensure that my components directory stays client-side and the rest within views is server-side. If it's only client-side where is the path located for server-side views?

If you need any more information feel free to ask :) Thanks!

app.js

'use strict';

var Client = require('react-engine/lib/client');

require('./views/**/*.jsx', {glob: true});

var options = {
  viewResolver: function(viewName) {
    return require('./views/' + viewName);
  }
}

document.addEventListener('DOMContentLoaded', function onLoad() {
  Client.boot(options);
})
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

1 participant