Send initial state in a <script type="application/json"> tag (#1806)

This commit is contained in:
Joachim Viide authored and Eugen committed 2017-04-15 02:32:42 +02:00
1 parent 9240ca6cef
commit ef879a8839
9 files changed
+25 -17

No files matched your search

@@ -61,8 +61,8 @@ import { hydrateStore } from '../actions/store';
import createStream from '../stream';
const store = configureStore();
store.dispatch(hydrateStore(window.INITIAL_STATE));
const initialState = JSON.parse(document.getElementById("initial-state").textContent);
store.dispatch(hydrateStore(initialState));
const browserHistory = useRouterHistory(createBrowserHistory)({
basename: '/web'
@@ -95,9 +95,10 @@ const Mastodon = React.createClass({
componentDidMount() {
const { locale } = this.props;
const streamingAPIBaseURL = store.getState().getIn(['meta', 'streaming_api_base_url']);
const accessToken = store.getState().getIn(['meta', 'access_token']);
this.subscription = createStream(accessToken, 'user', {
this.subscription = createStream(streamingAPIBaseURL, accessToken, 'user', {
connected () {
store.dispatch(connectTimeline('home'));