componentWillMount vs componentDidMount
crapthings opened this issue · comments
componentWillMount vs componentDidMount
what is different between
componentWillMount() {
this.data = {};
this._meteorDataManager = new MeteorDataManager(this);
const newData = this._meteorDataManager.calculateData();
this._meteorDataManager.updateData(newData);
}
componentDidMount() {
this.data = {};
this._meteorDataManager = new MeteorDataManager(this);
const newData = this._meteorDataManager.calculateData();
this._meteorDataManager.updateData(newData);
}
if we use react-router or flow-router + react-mounter then we make a subscribe withTracker
when switching route, next component's componentWillMount will happen before previous component's componentWillUnmount. is this a correct behavior?
this will cause minimongo's remain previous subscription's records, it reruns component while previous records are removed one by one.
the ddp message is always show
sub first then unsub
this will cause unwanted rerun, screen flick.
then i try to make a container like what react-meteor-data does then move subscribe to "componentDidMount" and "componentWillUnmount" to stop tracker first and subscribeHandler
the order looks good now, and stop subscribe does what meteor docs said
stop()
Cancel the subscription. This will typically result in the server directing the client to remove the subscription’s data from the client’s cache.
some issue relative to this.
Clean client side minimongo?
meteor/meteor-feature-requests#242
@crapthings PR definitely welcome
closing because of react-meteor-data@2.0.0 #273