mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-11-04 22:40:29 +03:00
Use proper deep comparison for hasChanged
This commit is contained in:
parent
cfee62ffe6
commit
4c5acc1940
1 changed files with 2 additions and 2 deletions
|
|
@ -6,6 +6,7 @@ import React, {
|
||||||
useMemo,
|
useMemo,
|
||||||
useState,
|
useState,
|
||||||
} from 'react';
|
} from 'react';
|
||||||
|
import { deepCompare } from 'matrix-js-sdk/lib/utils';
|
||||||
import { ExtendedProfile } from '../../../../hooks/useExtendedProfile';
|
import { ExtendedProfile } from '../../../../hooks/useExtendedProfile';
|
||||||
|
|
||||||
type ExtendedProfileKeys = keyof {
|
type ExtendedProfileKeys = keyof {
|
||||||
|
|
@ -71,8 +72,7 @@ export function ProfileFieldContext<C>({
|
||||||
() =>
|
() =>
|
||||||
Object.entries(fields).find(
|
Object.entries(fields).find(
|
||||||
([key, value]) =>
|
([key, value]) =>
|
||||||
// this is a hack but ExtendedProfile is always valid JSON anyway
|
deepCompare(fieldDefaults[key as keyof ExtendedProfile], value)
|
||||||
JSON.stringify(fieldDefaults[key as keyof ExtendedProfile]) !== JSON.stringify(value)
|
|
||||||
) !== undefined,
|
) !== undefined,
|
||||||
[fields, fieldDefaults]
|
[fields, fieldDefaults]
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue