From 9d0bd799b9bd7396e65ea1531bd43ce0c9d71ce4 Mon Sep 17 00:00:00 2001 From: Mark Erikson Date: Sun, 17 Apr 2016 21:35:57 -0400 Subject: [PATCH] Replace use of React-Transform reloading with normal Webpack HMR Per https://github.com/reactjs/redux/pull/1455, use of the "plain" Webpack HMR API for hot-loading can be simpler and easier to manage. --- src/components/CesiumBillboard.jsx | 12 ++++----- src/index.js | 43 +++++++++++++++++++++++++++--- 2 files changed, 45 insertions(+), 10 deletions(-) diff --git a/src/components/CesiumBillboard.jsx b/src/components/CesiumBillboard.jsx index bc7037d..2b23f90 100644 --- a/src/components/CesiumBillboard.jsx +++ b/src/components/CesiumBillboard.jsx @@ -8,18 +8,16 @@ export default class CesiumBillboard extends Component { componentDidMount() { const {scene} = this.props; - this.billboards = new BillboardCollection(); if(scene) { scene.primitives.add(this.billboards); } - - this.billboard = this.billboards.add({ position : Cesium.Cartesian3.fromDegrees(-117.0, 35.0, 10000), - image : fireflyIcon + image : fireflyIcon, + //scale : 0.5 }); } @@ -29,11 +27,13 @@ export default class CesiumBillboard extends Component { componentWillUnmount() { const {scene} = this.props; - if(scene) { + if(scene && !scene.isDestroyed()) { scene.primitives.remove(this.billboards); } - this.billboards.destroy(); + if(this.billboards && !this.billboards.isDestroyed()) { + this.billboards.destroy(); + } } } diff --git a/src/index.js b/src/index.js index 08fc31e..f3b6811 100644 --- a/src/index.js +++ b/src/index.js @@ -24,8 +24,43 @@ const store = configureStore(); window.React = React; +const rootEl = document.getElementById("root"); -ReactDOM.render( - , - document.getElementById("root") -); + + +let render = () => { + const Root = require("containers/Root").default; + ReactDOM.render( + , + rootEl + ); +}; + + +if(module.hot) { + // Support hot reloading of components + // and display an overlay for runtime errors + const renderApp = render; + const renderError = (error) => { + const RedBox = require("redbox-react"); + ReactDOM.render( + , + rootEl, + ); + }; + + render = () => { + try { + renderApp(); + } + catch(error) { + renderError(error); + } + }; + + module.hot.accept("./containers/Root", () => { + setTimeout(render); + }); +} + +render(); \ No newline at end of file