mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-26 17:16:11 -05:00
Consolidate rendering to helper function
This commit is contained in:
parent
da9174c520
commit
07be335a42
6 changed files with 24 additions and 33 deletions
13
src/lib/renderer.jsx
Normal file
13
src/lib/renderer.jsx
Normal file
|
@ -0,0 +1,13 @@
|
|||
var React = require('react');
|
||||
|
||||
var Renderer = {
|
||||
render: function (jsx, toElement) {
|
||||
var rendered = React.render(jsx, toElement);
|
||||
if (process.env.NODE_ENV != 'production') {
|
||||
window.renderedComponents = window.renderedComponents || [];
|
||||
window.renderedComponents.push(rendered);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = Renderer;
|
12
src/main.jsx
12
src/main.jsx
|
@ -1,15 +1,9 @@
|
|||
var React = require('react');
|
||||
var Renderer = require('./lib/renderer.jsx');
|
||||
|
||||
require('./main.scss');
|
||||
|
||||
var Navigation = require('./components/navigation/navigation.jsx');
|
||||
var Footer = require('./components/footer/footer.jsx');
|
||||
|
||||
var renderedNavigation = React.render(<Navigation />, document.getElementById('navigation'));
|
||||
var renderedFooter = React.render(<Footer />, document.getElementById('footer'));
|
||||
|
||||
if (process.env.NODE_ENV != 'production') {
|
||||
window.renderedComponents = window.renderedComponents || [];
|
||||
window.renderedComponents.push(renderedNavigation);
|
||||
window.renderedComponents.push(renderedFooter);
|
||||
}
|
||||
Renderer.render(<Navigation />, document.getElementById('navigation'));
|
||||
Renderer.render(<Footer />, document.getElementById('footer'));
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
var React = require('react');
|
||||
var Renderer = require('../../lib/renderer.jsx');
|
||||
|
||||
require('./about.scss');
|
||||
|
||||
|
@ -13,9 +14,4 @@ var About = React.createClass({
|
|||
}
|
||||
});
|
||||
|
||||
var renderedView = React.render(<About />, document.getElementById('view'));
|
||||
|
||||
if (process.env.NODE_ENV != 'production') {
|
||||
window.renderedComponents = window.renderedComponents || [];
|
||||
window.renderedComponents.push(renderedView);
|
||||
}
|
||||
Renderer.render(<About />, document.getElementById('view'));
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
var React = require('react');
|
||||
var Renderer = require('../../lib/renderer.jsx');
|
||||
|
||||
var Box = require('../../components/box/box.jsx');
|
||||
var Button = require('../../components/forms/button.jsx');
|
||||
|
@ -36,9 +37,4 @@ var Components = React.createClass({
|
|||
}
|
||||
});
|
||||
|
||||
var renderedView = React.render(<Components />, document.getElementById('view'));
|
||||
|
||||
if (process.env.NODE_ENV != 'production') {
|
||||
window.renderedComponents = window.renderedComponents || [];
|
||||
window.renderedComponents.push(renderedView);
|
||||
}
|
||||
Renderer.render(<Components />, document.getElementById('view'));
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
var React = require('react');
|
||||
var Renderer = require('../../lib/renderer.jsx');
|
||||
|
||||
require('./hoc.scss');
|
||||
|
||||
|
@ -104,9 +105,4 @@ var Hoc = React.createClass({
|
|||
}
|
||||
});
|
||||
|
||||
var renderedView = React.render(<Hoc />, document.getElementById('view'));
|
||||
|
||||
if (process.env.NODE_ENV != 'production') {
|
||||
window.renderedComponents = window.renderedComponents || [];
|
||||
window.renderedComponents.push(renderedView);
|
||||
}
|
||||
Renderer.render(<Hoc />, document.getElementById('view'));
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
var React = require('react');
|
||||
var Renderer = require('../../lib/renderer.jsx');
|
||||
|
||||
var Api = require('../../mixins/api.jsx');
|
||||
var Session = require('../../mixins/session.jsx');
|
||||
|
@ -72,9 +73,4 @@ var Splash = React.createClass({
|
|||
}
|
||||
});
|
||||
|
||||
var renderedView = React.render(<Splash />, document.getElementById('view'));
|
||||
|
||||
if (process.env.NODE_ENV != 'production') {
|
||||
window.renderedComponents = window.renderedComponents || [];
|
||||
window.renderedComponents.push(renderedView);
|
||||
}
|
||||
Renderer.render(<Splash />, document.getElementById('view'));
|
||||
|
|
Loading…
Reference in a new issue