Socket
Socket
Sign inDemoInstall

react-view-engine

Package Overview
Dependencies
35
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-view-engine

An express.js view engine for server and client side react


Version published
Weekly downloads
9
decreased by-52.63%
Maintainers
1
Install size
8.13 MB
Created
Weekly downloads
 

Readme

Source

This is a library for allowing server and client side rendering of react components.

npm install react-view-engine --save

then in your express app.js

var engine = require('./react-view-engine');

//Use this function to initialize node-jsx, if your react files are .jsx
engine.initJSX()

app.engine('js', engine.engine);
app.use(engine.handler);

from then on you can use the normal res.render function of express.

The react view must be loaded normally to the clientside somewhere.

In your react view you must add the loadProps(View, View.displayName) if you want to load the view props on the clientside.

/**
 * @jsx React.DOM
*/

var React = require('react');

var ClientApp = React.createClass({
  render: function() {
    return (
      <html>
        <head>
          <script src="/js/client.js"/>
        </head>
        <body>
          <h1>{this.props.name}</h1>
        </body>
      </html>
    );
  }
});

module.exports = ClientApp;

if(typeof window != "undefined"){
  window.addEventListener('load', function(){
    loadProps(ClientApp, ClientApp.displayName)
  })
}

Keywords

FAQs

Last updated on 18 Nov 2014

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc