Skip to content
This repository has been archived by the owner on Nov 15, 2017. It is now read-only.

Commit

Permalink
Split data/component rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
swernerx committed Feb 13, 2017
1 parent 259b3a4 commit b5bfe6a
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions src/client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,29 @@ import { createApolloClient, createReduxStore } from "../common/Data"
// Get the DOM Element that will host our React application.
const container = document.querySelector("#app")

function renderApp(RenderContainer)

let apolloClient
let reduxStore

function renderDataApp(RenderContainer)
{
console.log("Client: Initialize state from server:", window.APP_STATE)
const apolloClient = createApolloClient({
apolloClient = createApolloClient({
initialState: window.APP_STATE
})

const reduxStore = createReduxStore({
reduxStore = createReduxStore({
reducers: RenderContainer.getReducers(),
enhancers: RenderContainer.getEnhancers(),
middlewares: RenderContainer.getMiddlewares(),
initialState: window.APP_STATE
})

return renderApp(RenderContainer)
}

function renderApp(RenderContainer)
{
var fullApp = (
<ReactHotLoader>
<BrowserRouter>
Expand Down Expand Up @@ -55,7 +64,13 @@ if (process.env.NODE_ENV === "development" && module.hot)
module.hot.accept("./index.js")

// Any changes to our App will cause a hotload re-render.
// module.hot.accept("../app/AppContainer", () => renderApp(require("../app/AppContainer").default))
module.hot.accept("../app/AppContainer", () => {
let nextRoot = require("../app/AppContainer").default
console.log("Reloaded root container: ", nextRoot)
renderApp(nextRoot)


})
}

renderApp(AppContainer)
renderDataApp(AppContainer)

0 comments on commit b5bfe6a

Please sign in to comment.