Skip to content

Commit

Permalink
try to call render after module executed
Browse files Browse the repository at this point in the history
  • Loading branch information
mikz committed Jan 24, 2016
1 parent 683de2f commit 3fc30e2
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 29 deletions.
31 changes: 2 additions & 29 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,3 @@
import React from 'react'
import ReactDOM from 'react-dom'
import { Provider } from 'react-redux'
import configureStore from './store'
import { render } from './main'

import DevTools from './containers/dev_tools'
import Counter from './containers/counter'
import HelloWorld from './containers/hello_world'
import reducers from './reducers/index';

const store = window.__store || configureStore(reducers)
delete window.__store

export function __unload() {
window.__store = store;
}

export function __reload(deletedModule) {
store.replaceReducer(reducers)
}

ReactDOM.render((
<Provider store={store}>
<div>
<HelloWorld />
<Counter />
<DevTools />
</div>
</Provider>
), document.getElementById('app'))
render(document.getElementById('app'))
28 changes: 28 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React from 'react'
import ReactDOM from 'react-dom'
import { Provider } from 'react-redux'
import configureStore from './store'

import DevTools from './containers/dev_tools'
import Counter from './containers/counter'
import HelloWorld from './containers/hello_world'
import reducers from './reducers/index';

export let store = configureStore(reducers)

export function __reload(deletedModule) {
store = deletedModule.store
store.replaceReducer(reducers)
}

export function render(element) {
ReactDOM.render((
<Provider store={store}>
<div>
<HelloWorld />
<Counter />
<DevTools />
</div>
</Provider>
), element)
}

0 comments on commit 3fc30e2

Please sign in to comment.