Skip to content
This repository was archived by the owner on Jan 13, 2022. It is now read-only.
This repository was archived by the owner on Jan 13, 2022. It is now read-only.

setState warning and too many getMeteorState calls #84

@froatsnook

Description

@froatsnook

Hi,

See repro here: https://github.com/froatsnook/meteor-react-set-state-warning

I'm seeing a ton of these:
Warning: setState(...): Can only update a mounted or mounting component. This usually means you called setState() on an unmounted component. This is a no-op.

Basically I have:

TestList = ReactMeteor.createClass({

    getMeteorState: function() {
        return {
            tests: Tests.find(this.props.query).fetch()
        };
    },

    render: function() {
        var items = this.state.tests.map(function(test) { return <Test _id={test._id} key={test._id} />; };
        return <div>{items}</div>;
    }
});

where <Test /> is:

Test = ReactMeteor.createClass({
    getMeteorState: function() {
        return Tests.findOne(this.props._id_;
    },
});

Every time query changes in TestList, getMeteorState gets called in each Test, even though the Test itself doesn't change..

EDIT: OK, so implementing shouldComponentUpdate removes the warning. But is it necessary that getMeteorState be called? Intuitively it doesn't seem necessary, but maybe I don't understand this well enough.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions