Last active
August 29, 2015 14:26
-
-
Save smashercosmo/7bed813bd4ceb4dd2da9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import Router from 'react-router'; | |
import routes from './routes'; | |
import { createStore, combineReducers } from 'redux'; | |
import { Provider } from 'react-redux'; | |
import intlReducer from './intl/intl.reducer' | |
const app = document.getElementById('app'); | |
/** initalState contains very complicated object with all translations */ | |
const initialState = window._initialState; | |
const reducer = combineReducers({ intl: intlReducer }); | |
const createStoreWithMiddleware = applyMiddleware(thunk)(createStore); | |
const store = createStoreWithMiddleware(reducer, initialState); | |
Router.run(routes, Router.HistoryLocation, (Handler) => { | |
React.render( | |
<Provider store={store}> | |
{() => <Handler />} | |
</Provider>, app); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
export default class Header extends React.Component { | |
static propTypes = { | |
msg: React.PropTypes.object.isRequired | |
}; | |
render() { | |
const {msg} = this.props; | |
return ( | |
<header> | |
{/* initially there is no app.header, because reducer trigger dummy action with empty object as initial state */} | |
{msg.app.header} | |
</header> | |
); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** i can't provide initial state, that has the same structure as translation object, because it's realy big and has multiple levels */ | |
var initialState = {}; | |
export default function intl(state = initialState) { | |
return state; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment