Avoid unnecessary re-render on CHECK_NETWORK_STATUS
This commit is contained in:
parent
b70b7a2cee
commit
55091edefa
3 changed files with 138 additions and 3 deletions
|
@ -3,6 +3,7 @@
|
|||
|
||||
import { SocketStatus } from '../../types/SocketStatus';
|
||||
import { trigger } from '../../shims/events';
|
||||
import { assignWithNoUnnecessaryAllocation } from '../../util/assignWithNoUnnecessaryAllocation';
|
||||
|
||||
// State
|
||||
|
||||
|
@ -89,11 +90,12 @@ export function reducer(
|
|||
if (action.type === CHECK_NETWORK_STATUS) {
|
||||
const { isOnline, socketStatus } = action.payload;
|
||||
|
||||
return {
|
||||
...state,
|
||||
// This action is dispatched frequently. We avoid allocating a new object if nothing
|
||||
// has changed to avoid an unnecessary re-render.
|
||||
return assignWithNoUnnecessaryAllocation(state, {
|
||||
isOnline,
|
||||
socketStatus,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
if (action.type === CLOSE_CONNECTING_GRACE_PERIOD) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue