Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcc5f049

Browse files
committed
New render optimization test
1 parentf0cd910 commitcc5f049

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

‎test/components/connect.spec.js‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,5 +1193,38 @@ describe('React', () => {
11931193
TestUtils.Simulate.click(node);
11941194
expect(childMapStateExecuted).toBe(true);
11951195
});
1196+
1197+
it('should not render the wrapped component when mapState does not produce change',()=>{
1198+
conststore=createStore(stringBuilder);
1199+
letrenderCalls=0;
1200+
letmapStateCalls=0;
1201+
1202+
@connect(()=>{
1203+
mapStateCalls++;
1204+
return{};// no change!
1205+
})
1206+
classContainerextendsComponent{
1207+
render(){
1208+
renderCalls++;
1209+
return<Passthrough{...this.props}/>;
1210+
}
1211+
}
1212+
1213+
TestUtils.renderIntoDocument(
1214+
<ProviderMockstore={store}>
1215+
<Container/>
1216+
</ProviderMock>
1217+
);
1218+
1219+
expect(renderCalls).toBe(1);
1220+
expect(mapStateCalls).toBe(1);
1221+
1222+
store.dispatch({type:'APPEND',body:'a'});
1223+
1224+
// After store a change mapState has been called
1225+
expect(mapStateCalls).toBe(2);
1226+
// But render is not because it did not make any actual changes
1227+
expect(renderCalls).toBe(1);
1228+
});
11961229
});
11971230
});

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp