Skip to content
This repository has been archived by the owner on Dec 5, 2019. It is now read-only.

Commit

Permalink
React 0.12 fixes #4
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Nov 25, 2014
1 parent bd32ee5 commit 187773e
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 34 deletions.
4 changes: 1 addition & 3 deletions example/app.jsx
@@ -1,5 +1,3 @@
/** @jsx React.DOM */

var React = require("react");
var LinkedStateMixin = require("react/lib/LinkedStateMixin");

Expand Down Expand Up @@ -51,4 +49,4 @@ var App = React.createClass({
}
});

React.renderComponent(<App />, document.body);
React.render(<App />, document.body);
1 change: 0 additions & 1 deletion example/b.jsx
Expand Up @@ -3,7 +3,6 @@
var React = require("react");
var B = React.createClass({
render: function() {
// Can be changed and updated without full page refresh
return <p>This is component B.</p>;
}
});
Expand Down
1 change: 0 additions & 1 deletion example/c.jsx
Expand Up @@ -7,7 +7,6 @@ var C = React.createClass({
return { text: "Text" };
},
render: function() {
// Can be changed and updated without full page refresh
return (
<div>
<p>This is component C ({this.props.param}).</p>
Expand Down
1 change: 0 additions & 1 deletion example/d.jsx
Expand Up @@ -3,7 +3,6 @@
var React = require("react");
var D = React.createClass({
render: function() {
// Can be changed and updated without full page refresh
return <p>This is component D.</p>;
}
});
Expand Down
4 changes: 3 additions & 1 deletion example/webpack.config.js
@@ -1,8 +1,10 @@
// Run with "webpack-dev-server --hot --inline --colors"

var path = require("path");
var webpack = require("webpack");

module.exports = {
entry: ["webpack/hot/dev-server", "./app"],
entry: "./app",
output: {
path: path.join(__dirname, "output"),
filename: "bundle.js"
Expand Down
25 changes: 10 additions & 15 deletions index.js
@@ -1,28 +1,23 @@
var loaderUtils = require("loader-utils");

module.exports = function() {};
module.exports.pitch = function(remainingRequest) {
this.cacheable && this.cacheable();
var query = loaderUtils.parseQuery(this.query);
var moduleRequest = "!!" + require.resolve("bundle-loader") + "?lazy!" + remainingRequest;
var moduleRequest = "!!" + remainingRequest;
return [
'var React = require("react");',
'var ReactTextComponent = require("react/lib/ReactTextComponent.js");',
'var component;',
'var desc = {',
' loadComponent: function(callback) {',
' var ret;',
' require(' + JSON.stringify(moduleRequest) + ')(function(component) {',
' ret = component;',
' if(callback) callback(component);',
' });',
' return ret;',
' if(!component) {',
' require.ensure([], function() {',
' component = require(' + JSON.stringify(moduleRequest) + ');',
' if(callback) callback(component);',
' });',
' } else if(callback) callback(component);',
' return component;',
' },',
' _renderUnavailable: function() {',
' return new ReactTextComponent("");',
' }',
'};',
'var mixinReactProxy = require(' + JSON.stringify(require.resolve("./mixinReactProxy")) + ');',
'mixinReactProxy(desc);',
'mixinReactProxy(React, desc);',
'module.exports = React.createClass(desc);',
'module.exports.Mixin = desc;'
].join("\n");
Expand Down
8 changes: 4 additions & 4 deletions mixinReactProxy.js
@@ -1,13 +1,13 @@
module.exports = function(desc) {
module.exports = function(React, desc) {
desc.displayName = "ReactProxy";
desc.render = function() {
var Component = this.state.component;
if(Component) {
return this.transferPropsTo(Component(null, this.props.children));
return React.createElement(Component, this.props, this.props.children);
} else if(this.renderUnavailable) {
return this.renderUnavailable()
return this.renderUnavailable();
} else {
return this._renderUnavailable()
return null;
}
};
desc.getInitialState = function() {
Expand Down
12 changes: 4 additions & 8 deletions package.json
Expand Up @@ -7,9 +7,9 @@
"example": "example"
},
"devDependencies": {
"react": "^0.10.0",
"jsx-loader": "^0.10.2",
"webpack": "^1.3.1"
"react": "^0.12.0",
"jsx-loader": "^0.12.0",
"webpack": "^1.4.1"
},
"scripts": {
"test": "mocha -R spec"
Expand All @@ -30,9 +30,5 @@
"bugs": {
"url": "https://github.com/webpack/react-proxy-loader/issues"
},
"homepage": "https://github.com/webpack/react-proxy-loader",
"dependencies": {
"bundle-loader": "^0.5.0",
"loader-utils": "^0.2.3"
}
"homepage": "https://github.com/webpack/react-proxy-loader"
}

0 comments on commit 187773e

Please sign in to comment.