Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for eslint error "Do not use setState in componentDidMount react/no-did-mount-set-state" #141

Closed
stevus opened this issue Nov 6, 2015 · 4 comments

Comments

@stevus
Copy link

stevus commented Nov 6, 2015

In L81 (and other map/components}):

should be instead:

componentWillReceiveProps (nextProps) {

    if(typeof this.state.map === 'undefined') {
        const domEl = findDOMNode(this);
        const {containerTagName, containerProps, children, ...mapProps} = nextProps;
        const map = GoogleMapHolder._createMap(domEl, mapProps);
        this.setState({ map });
    }
}

otherwise will fail ES2015 eslinting

error  Do not use setState in componentDidMount       react/no-did-mount-set-state
@tomchentw
Copy link
Owner

We really want it to happen in cDM because we need DOM node for google maps instance. Any ideas?

@tomchentw
Copy link
Owner

Use callback style ref in the new refactoring branch #157 .

@tomchentw
Copy link
Owner

Released v4.6.0

@stevus
Copy link
Author

stevus commented Nov 24, 2015

Awesome work, and quick response. I will try it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants