mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2025-01-20 19:09:58 -05:00
24 lines
743 B
React
24 lines
743 B
React
|
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);
|
||
|
}
|
||
|
};
|