New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

react-node-render

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-node-render

Simply render React components in Node.js

latest
Source
npmnpm
Version
0.0.7
Version published
Maintainers
1
Created
Source

Travis NPM version Coverage Status

react-node-render

Simply render React components in Node.js

Node_module

npm install react-node-render --save

const render = require('react-node-render')
const html = render('myComponent.jsx')
console.log(html)

With options

const html = render('myComponent.jsx', {initialCount:42})

Render to static

const html = render('myComponent.jsx', {initialCount:42},true)

Cli

Install:

npm install react-node-render -g

Use:

rnr myComponent.jsx

myComponent.html is now created

Input

import React from 'react'

import React from 'react'
class component extends React.Component {
	constructor(props) {
		super(props)
		this.state = {count: props.initialCount}
	}

	handleClick(){
		this.setState({count: this.state.count + 1})
	}
	render() {
		return (
			<div onClick={this.handleClick.bind(this)}>
				hello {this.state.count}
			</div>
		)
	}
}
component.defaultProps = { initialCount: 1337 }
export default component

Output

<div data-reactid=".2c8ppxl2l1c" data-react-checksum="-143512554"><span data-reactid=".2c8ppxl2l1c.0">hello </span><span data-reactid=".2c8ppxl2l1c.1">1337</span></div>

or with static mode:

<div>hello 1337</div>

notes

  • todo fix .babelrc dependency
  • render to jade
  • render to hbs
  • rendering with react-router
  • more awesome tests
  • deeper error handeling
  • more cli features

Created mainly to shoot out html for koa/express.js servers used together with a templating language.

Keywords

jrnl

FAQs

Package last updated on 04 Nov 2016

Did you know?

Socket

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