Skip to content

Commit

Permalink
feat: add node-rendering example / test
Browse files Browse the repository at this point in the history
  • Loading branch information
iam4x committed May 20, 2015
1 parent b4ba260 commit 7698c38
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ Installing is really simple and can be done in multiple ways:
- Start a static webserver `python -m SimpleHTTPServer`
- And visit `localhost:8000/example` to see the example.

You can also test server side rendering:

- `$ node example/node-rendering.js`

You should see the HTML returned.

To run tests, simply run `npm test`.

## License
Expand Down
24 changes: 24 additions & 0 deletions example/node-rendering.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
require('babel/register');

var React = require('react');
var moment = require('moment');
var DatePicker = require('../dist/react-datepicker.js');

var Example = React.createClass({
getInitialState: function () {
return {date: moment()};
},
onChange: function () {},
render: function () {
return React.createElement(
DatePicker,
{
selected: this.state.date,
onChange: this.handleChange
}
);
}
});

var html = React.renderToString(React.createElement(Example));
console.log(html);
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"url": "https://github.com/Hacker0x01/react-datepicker/issues"
},
"devDependencies": {
"babel": "^5.4.4",
"babel-core": "^4.7.3",
"babel-jest": "^4.0.0",
"babel-loader": "^4.1.0",
Expand Down

0 comments on commit 7698c38

Please sign in to comment.