Skip to content

Commit

Permalink
fix(docz-core): dispose hmr on imports
Browse files Browse the repository at this point in the history
  • Loading branch information
pedronauck committed Sep 2, 2018
1 parent e531c53 commit ba51086
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
8 changes: 1 addition & 7 deletions packages/docz-core/templates/index.tpl.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<% if (!isProd) {%>import 'webpack-serve-overlay'<%}%>
import React from 'react'
import ReactDOM from 'react-dom'

import { imports } from './imports'
import Root from './root'

const _onPreRenders = [<% if (onPreRenders) {%><%- onPreRenders %><%}%>]
Expand All @@ -14,11 +12,7 @@ const onPostRender = () => _onPostRenders.forEach(f => f && f())
const root = document.querySelector('#root')
const render = (Component = Root) => {
onPreRender()
ReactDOM.render(<Component imports={imports} />, root, onPostRender)
}

if (module.hot) {
module.hot.accept('./imports', () => render(Root))
ReactDOM.render(<Component />, root, onPostRender)
}

render(Root)
4 changes: 3 additions & 1 deletion packages/docz-core/templates/root.tpl.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import React from 'react'
import { hot } from 'react-hot-loader'
import Theme from '<%- theme %>'

import { imports } from './imports'
import db from './db.json'

<% if (wrapper) {%>import Wrapper from '<%- wrapper %>'<%}%>

const Root = ({ imports }) => (
const Root = () => (
<Theme
db={db}
imports={imports}
Expand Down

0 comments on commit ba51086

Please sign in to comment.