ChatResource: prevent unnecessary state update

This commit is contained in:
Liam Fitzgerald 2021-04-24 12:23:45 +10:00
parent 47c19b60c0
commit f79e489d67
No known key found for this signature in database
GPG Key ID: D390E12C61D1CFFB

View File

@ -75,7 +75,14 @@ export function ChatResource(props: ChatResourceProps) {
);
const clearUnsent = useCallback(
() => setUnsent(s => _.omit(s, station)),
() => {
setUnsent(s => {
if(station in s) {
return _.omit(s, station);
}
return s;
});
},
[station]
);