WA-234 Fix unnecesary re-renders when storing again just fetched safe

This commit is contained in:
apanizo 2018-06-13 15:48:43 +02:00
parent 161b0976ba
commit 1e51a48250
3 changed files with 8 additions and 3 deletions

View File

@ -18,7 +18,9 @@ class SafeView extends React.PureComponent<Props> {
if (!safe) { return }
const safeAddress: string = safe.get('address')
fetchBalance(safeAddress)
if (safe) {
fetchSafe(safe)
}
}, 1500)
}

View File

@ -24,7 +24,8 @@ action: AddSafeType
export default handleActions({
[UPDATE_SAFE]: (state: State, action: ActionType<typeof updateSafe>): State =>
state.set(action.payload.get('address'), action.payload),
state.update(action.payload.get('address'), prevSafe =>
(prevSafe.equals(action.payload) ? prevSafe : action.payload)),
[UPDATE_SAFES]: (state: State, action: ActionType<typeof updateSafes>): State =>
action.payload,
[ADD_SAFE]: (state: State, action: ActionType<typeof addSafe>): State => {

View File

@ -75,7 +75,9 @@ export const safeSelector: Selector<GlobalState, RouterProps, SafeSelectorProps>
return undefined
}
return safes.get(address)
const safe = safes.get(address)
return safe
},
)