Repository: mobxjs/mobx-react

Issue #12: forceUpdate: Can only update a mounted or mounting component.
Created: 2015-12-16T02:38:17Z
Hi. I'm getting the warning below in the console log.
My app has a table with a detail view next to it. The detail view shows the selected table row. The table also highlights the row under the mouse. As notifications arrive from the server, some items will disappear from the table. All this works fine, except for the warning.
I think it happens when the mouse is over the selected table row and the selected item disappears as instructed by the server. It looks as though it's trying to then update the detail view, which has disappeared. I'm using react and mobservable in the obvious way, so I'm wondering whether this should be handled differently by mobservable somehow?
warning.js:45 Warning: forceUpdate(...): Can only update a mounted or mounting component. This usually means you called forceUpdate() on an unmounted component. This is a no-op. Please check the code for the undefined component.

warning @   warning.js:45
getInternalInstanceReadyForUpdate   @   ReactUpdateQueue.js:34
ReactUpdateQueue.enqueueForceUpdate @   ReactUpdateQueue.js:135
ReactComponent.forceUpdate  @   ReactComponent.js:86
reactiveRender  @   index.js:60
ObservableView.compute  @   observableview.js:57
(anonymous function)    @   dnode.js:198
withStrict  @   core.js:301
ViewNode.computeNextState   @   dnode.js:197
ViewNode.notifyStateChange  @   dnode.js:182
DataNode.notifyObservers    @   dnode.js:113
DataNode.markReady  @   dnode.js:107
ObservableValue.set @   observablevalue.js:34
ObservableObject.defineReactiveProperty.Object.defineProperty.set   @   observableobject.js:61
ListVModelMasterObservable.setHighlightedId @   listViewModelObservable.ts:182
TableRow.render.React.createElement.onMouseEnter    @   choresByReact.tsx:121
ReactErrorUtils.invokeGuardedCallback   @   ReactErrorUtils.js:71
executeDispatch @   EventPluginUtils.js:79
executeDispatchesInOrder    @   EventPluginUtils.js:102
executeDispatchesAndRelease @   EventPluginHub.js:43
executeDispatchesAndReleaseTopLevel @   EventPluginHub.js:54
forEachAccumulated  @   forEachAccumulated.js:23
EventPluginHub.processEventQueue    @   EventPluginHub.js:259
runEventQueueInBatch    @   ReactEventEmitterMixin.js:18
ReactEventEmitterMixin.handleTopLevel   @   ReactEventEmitterMixin.js:34
handleTopLevelWithoutPath   @   ReactEventListener.js:93
handleTopLevelImpl  @   ReactEventListener.js:73
Mixin.perform   @   Transaction.js:136
ReactDefaultBatchingStrategy.batchedUpdates @   ReactDefaultBatchingStrategy.js:62
batchedUpdates  @   ReactUpdates.js:94
ReactEventListener.dispatchEvent    @   ReactEventListener.js:204

Duplicate issue #9: Error when unmounting component has componentWillMount() without componentWillUnmount() method defined 
Created: 2015-12-02T13:55:54Z
Uncaught TypeError: Cannot read property 'forEach' of undefined

Error references to line 94 in node_modules/mobservable-react/index.js, that states
this.__$mobDependencies.forEach(function(dep) {
    dep.setRefCount(-1);
});

This happens when component has @observer decorator and has own componentWillMount() defined but does not have own componentWillUnmount(). Adding empty componentWillUnmount() method to component makes the error go away.

Closing comment (2015-12-18T14:12:16Z): forceUpdate error might be a duplicate of: #12