mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Add a failing test case for #6742
getOperations() blows up when replacing null with a native because the null component has debugID of 0 that isn’t registered in the component tree.
This commit is contained in:
@@ -67,6 +67,13 @@ describe('ReactPerf', function() {
|
||||
ReactPerf.start();
|
||||
fn();
|
||||
ReactPerf.stop();
|
||||
|
||||
// Make sure none of the methods crash.
|
||||
ReactPerf.getWasted();
|
||||
ReactPerf.getInclusive();
|
||||
ReactPerf.getExclusive();
|
||||
ReactPerf.getOperations();
|
||||
|
||||
return ReactPerf.getLastMeasurements();
|
||||
}
|
||||
|
||||
@@ -208,6 +215,32 @@ describe('ReactPerf', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('should not count replacing null with a native as waste', function() {
|
||||
var element = null;
|
||||
function Foo () {
|
||||
return element;
|
||||
}
|
||||
var container = document.createElement('div');
|
||||
ReactDOM.render(<Foo />, container);
|
||||
expectNoWaste(() => {
|
||||
element = <div />;
|
||||
ReactDOM.render(<Foo />, container);
|
||||
});
|
||||
});
|
||||
|
||||
it('should not count replacing a native with null as waste', function() {
|
||||
var element = <div />;
|
||||
function Foo () {
|
||||
return element;
|
||||
}
|
||||
var container = document.createElement('div');
|
||||
ReactDOM.render(<Foo />, container);
|
||||
expectNoWaste(() => {
|
||||
element = null;
|
||||
ReactDOM.render(<Foo />, container);
|
||||
});
|
||||
});
|
||||
|
||||
it('warns once when using getMeasurementsSummaryMap', function() {
|
||||
var measurements = measure(() => {});
|
||||
spyOn(console, 'error');
|
||||
|
||||
Reference in New Issue
Block a user