forked from ruanyf/react-demos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a new babel branch. deprecating JSTransform and react-tools
- Loading branch information
Showing
19 changed files
with
123 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
example/ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,49 @@ | ||
'use strict'; | ||
|
||
var React = require('react'); | ||
|
||
module.exports = React.createClass({displayName: "exports", | ||
module.exports = React.createClass({ | ||
displayName: 'exports', | ||
|
||
getInitialState: function() { | ||
getInitialState: function getInitialState() { | ||
return { | ||
items: this.props.items, | ||
disabled: true | ||
} | ||
}; | ||
}, | ||
|
||
componentDidMount: function() { | ||
componentDidMount: function componentDidMount() { | ||
this.setState({ | ||
disabled: false | ||
}) | ||
}); | ||
}, | ||
|
||
handleClick: function() { | ||
handleClick: function handleClick() { | ||
this.setState({ | ||
items: this.state.items.concat('Item ' + this.state.items.length) | ||
}) | ||
}); | ||
}, | ||
|
||
render: function() { | ||
return ( | ||
React.createElement("div", null, | ||
React.createElement("button", {onClick: this.handleClick, disabled: this.state.disabled}, "Add Item"), | ||
React.createElement("ul", null, | ||
|
||
this.state.items.map(function(item) { | ||
return React.createElement("li", null, item) | ||
}) | ||
|
||
) | ||
render: function render() { | ||
return React.createElement( | ||
'div', | ||
null, | ||
React.createElement( | ||
'button', | ||
{ onClick: this.handleClick, disabled: this.state.disabled }, | ||
'Add Item' | ||
), | ||
React.createElement( | ||
'ul', | ||
null, | ||
this.state.items.map(function (item) { | ||
return React.createElement( | ||
'li', | ||
null, | ||
item | ||
); | ||
}) | ||
) | ||
) | ||
}, | ||
}); | ||
); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
'use strict'; | ||
|
||
var React = require('react'); | ||
var App = require('./app'); | ||
|
||
React.render(React.createElement(App, {items: window.APP_PROPS.items}), document.getElementById('content')); | ||
React.render(React.createElement(App, { items: window.APP_PROPS.items }), document.getElementById('content')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,38 @@ | ||
'use strict'; | ||
|
||
var http = require('http'), | ||
browserify = require('browserify'), | ||
literalify = require('literalify'), | ||
React = require('react'); | ||
|
||
var App = require('./app'); | ||
|
||
http.createServer(function(req, res) { | ||
http.createServer(function (req, res) { | ||
if (req.url == '/') { | ||
res.setHeader('Content-Type', 'text/html'); | ||
var props = { | ||
items: [ | ||
'Item 0', | ||
'Item 1' | ||
] | ||
items: ['Item 0', 'Item 1'] | ||
}; | ||
var html = React.renderToStaticMarkup( | ||
React.createElement("body", null, | ||
React.createElement("div", {id: "content", dangerouslySetInnerHTML: {__html: | ||
React.renderToString(React.createElement(App, {items: props.items})) | ||
}}), ",", | ||
|
||
React.createElement("script", {dangerouslySetInnerHTML: {__html: | ||
'var APP_PROPS = ' + JSON.stringify(props) + ';' | ||
}}), | ||
React.createElement("script", {src: "//fb.me/react-0.13.1.min.js"}), | ||
React.createElement("script", {src: "/bundle.js"}) | ||
) | ||
); | ||
var html = React.renderToStaticMarkup(React.createElement( | ||
'body', | ||
null, | ||
React.createElement('div', { id: 'content', dangerouslySetInnerHTML: { __html: React.renderToString(React.createElement(App, { items: props.items })) | ||
} }), | ||
',', | ||
React.createElement('script', { dangerouslySetInnerHTML: { __html: 'var APP_PROPS = ' + JSON.stringify(props) + ';' | ||
} }), | ||
React.createElement('script', { src: '//fb.me/react-0.13.3.min.js' }), | ||
React.createElement('script', { src: '/bundle.js' }) | ||
)); | ||
res.end(html); | ||
|
||
} else if (req.url == '/bundle.js') { | ||
res.setHeader('Content-Type', 'text/javascript'); | ||
browserify() | ||
.add('./browser.js') | ||
.transform(literalify.configure({react: 'window.React'})) | ||
.bundle() | ||
.pipe(res); | ||
|
||
browserify().add('./browser.js').transform(literalify.configure({ react: 'window.React' })).bundle().pipe(res); | ||
} else { | ||
res.statusCode = 404; | ||
res.end(); | ||
} | ||
}).listen(3000, function(err) { | ||
}).listen(3000, function (err) { | ||
if (err) throw err; | ||
console.log('Listening on 3000...'); | ||
}) | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters