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

Commitd930c48

Browse files
committed
New render optimization test
1 parentada28db commitd930c48

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
@@ -1212,5 +1212,38 @@ describe('React', () => {
12121212
// store.dispatch({ type: 'APPEND', body: 'd'});
12131213
// expect(childMapStateInvokes).toBe(5);
12141214
});
1215+
1216+
it('should not render the wrapped component when mapState does not produce change',()=>{
1217+
conststore=createStore(stringBuilder);
1218+
letrenderCalls=0;
1219+
letmapStateCalls=0;
1220+
1221+
@connect(()=>{
1222+
mapStateCalls++;
1223+
return{};// no change!
1224+
})
1225+
classContainerextendsComponent{
1226+
render(){
1227+
renderCalls++;
1228+
return<Passthrough{...this.props}/>;
1229+
}
1230+
}
1231+
1232+
TestUtils.renderIntoDocument(
1233+
<ProviderMockstore={store}>
1234+
<Container/>
1235+
</ProviderMock>
1236+
);
1237+
1238+
expect(renderCalls).toBe(1);
1239+
expect(mapStateCalls).toBe(2);
1240+
1241+
store.dispatch({type:'APPEND',body:'a'});
1242+
1243+
// After store a change mapState has been called
1244+
expect(mapStateCalls).toBe(3);
1245+
// But render is not because it did not make any actual changes
1246+
expect(renderCalls).toBe(1);
1247+
});
12151248
});
12161249
});

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp