Skip to content

Commit

Permalink
Replace use of React-Transform reloading with normal Webpack HMR
Browse files Browse the repository at this point in the history
Per reduxjs/redux#1455, use of the "plain"
Webpack HMR API for hot-loading can be simpler and easier to manage.
  • Loading branch information
markerikson committed Apr 18, 2016
1 parent 62ab019 commit 9d0bd79
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 10 deletions.
12 changes: 6 additions & 6 deletions src/components/CesiumBillboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
}

Expand All @@ -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();
}
}
}

Expand Down
43 changes: 39 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,43 @@ const store = configureStore();

window.React = React;

const rootEl = document.getElementById("root");

ReactDOM.render(
<Root store={store} />,
document.getElementById("root")
);


let render = () => {
const Root = require("containers/Root").default;
ReactDOM.render(
<Root store={store} />,
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(
<RedBox error={error} />,
rootEl,
);
};

render = () => {
try {
renderApp();
}
catch(error) {
renderError(error);
}
};

module.hot.accept("./containers/Root", () => {
setTimeout(render);
});
}

render();

0 comments on commit 9d0bd79

Please sign in to comment.