Skip to content

Commit

Permalink
fix(Map): add api loaded state to _initialized
Browse files Browse the repository at this point in the history
  • Loading branch information
tomchentw committed Nov 11, 2014
1 parent 3b0a0e0 commit 0e0192b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Map.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ module.exports = React.createClass({

getInitialState () {
return {
_initialized: false
/* [null, false, true] => ["init", "api loaded", "done"] */
_initialized: null,
};
},

Expand All @@ -57,6 +58,14 @@ module.exports = React.createClass({
ensure_map_created(this, this.add_listeners, create_map);
},

componentWillReceiveProps (nextProps, nextContext) {
if (null == this.state._initialized && nextContext.getApi()) {
this.setState({
_initialized: false,
});
}
},

componentWillUpdate () {
ensure_map_created(this, this.clear_listeners);
},
Expand Down

0 comments on commit 0e0192b

Please sign in to comment.