Skip to content
This repository has been archived by the owner on Dec 31, 2020. It is now read-only.

Dispose reaction on error inside rendering #134

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion test/observer.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,4 +300,33 @@ test("component should not be inject", function(t) {
t.equal(msg.length, 1);
console.warn = baseWarn;
t.end();
});
});

test("should stop updating if error was thrown in render (#134)", function(t) {
var data = mobx.observable(0);
var renderingsCount = 0;

var comp = observer(function() {
renderingsCount += 1;
if (data.get() === 2) {
throw new Error("Hello");
}
return e("div", {});
});

ReactDOM.render(e(comp), testRoot, function() {
t.equal(data.observers.length, 1);
data.set(1);
t.throws(function() {
data.set(2);
}, "Hello");
t.equal(data.observers.length, 0);
data.set(3);
data.set(4);
data.set(5);

t.equal(renderingsCount, 3);

t.end();
});
});