scratch-www/src/lib/render.jsx
Matthew Taylor d69de477a1 Merge branch 'develop' of https://github.com/LLK/scratch-www into feature/conference-schedule
* 'develop' of https://github.com/LLK/scratch-www: (32 commits)
  Lint
  Bundle all locale data
  Don't bundle polyfills
  Set up Raven within init.js
  Prefix privacyPolicy message string
  Exclude minified javascript from linting
  One space more
  Changes "interfacesto" to "interfaces to"
  Remove tag target
  Filter before mapping to avoid returning undefined
  Fix Pass condition for "static" routes
  Spacing2
  Mangling is the default
  Spacing
  Update for typography fixes
  Cherry pick PR #476 into master
  Add invisible spacer to anchored sections
  For Developers
  Lint JSON, expand and simplify lint step
  Fix banned user redirect
  ...

# Conflicts:
#	src/redux/actions.js
#	src/redux/reducer.js
2016-05-19 13:25:36 -04:00

49 lines
1.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

var redux = require('redux');
var thunk = require('redux-thunk').default;
// JSX syntax transforms to React.createElement
var React = require('react'); // eslint-disable-line
var ReactDOM = require('react-dom');
var StoreProvider = require('react-redux').Provider;
var IntlProvider = require('./intl.jsx').IntlProvider;
var authActions = require('../redux/auth.js');
var reducer = require('../redux/reducer.js');
require('../main.scss');
var store = redux.createStore(
reducer,
redux.applyMiddleware(thunk)
);
var render = function (jsx, element) {
// Get locale and messages from global namespace (see "init.js")
var locale = window._locale || 'en';
var messages = {};
if (typeof window._messages !== 'undefined') {
if (typeof window._messages[locale] === 'undefined') {
// Fall back on the split
locale = locale.split('-')[0];
}
if (typeof window._messages[locale] === 'undefined') {
// Language appears to not be supported fall back to 'en'
locale = 'en';
}
messages = window._messages[locale];
}
// Render view component
ReactDOM.render(
<StoreProvider store={store}>
<IntlProvider locale={locale} messages={messages}>
{jsx}
</IntlProvider>
</StoreProvider>,
element
);
// Get initial session
store.dispatch(authActions.refreshSession());
};
module.exports = render;