mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2025-05-16 15:51:19 -04:00
Rename renderer
to render
and make it a method that returns a component, rather than an object with a render method
This commit is contained in:
parent
b8972d545c
commit
0577860f3a
7 changed files with 34 additions and 24 deletions
src/lib
23
src/lib/render.jsx
Normal file
23
src/lib/render.jsx
Normal file
|
@ -0,0 +1,23 @@
|
|||
var ReactDOM = require('react-dom');
|
||||
var ReactIntl = require('react-intl');
|
||||
var IntlProvider = ReactIntl.IntlProvider;
|
||||
|
||||
module.exports = function (jsx, element) {
|
||||
// Get locale and messages from global namespace (see "init.js")
|
||||
var locale = window._locale;
|
||||
var messages = window._translations[locale];
|
||||
|
||||
// Render component
|
||||
var component = ReactDOM.render(
|
||||
<IntlProvider locale={locale} messages={messages}>
|
||||
{jsx}
|
||||
</IntlProvider>,
|
||||
element
|
||||
);
|
||||
|
||||
// If in production, provide list of rendered components
|
||||
if (process.env.NODE_ENV != 'production') {
|
||||
window._renderedComponents = window._renderedComponents || [];
|
||||
window._renderedComponents.push(component);
|
||||
}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue