Fixes infinite loop on record data update in command menu (#12072)
This PR fixes the infinite loop that was happening in `RecordShowEffect` component due to a useEffect on `recordStoreFamilyState` which was creating a non-deterministic open loop. The fix was to use a recoilCallback to avoid reading a stale state from Recoil with `useRecoilValue`, useRecoilCallback always gets the most fresh data and commits everything before React goes on with rendering, thus avoiding any stale value in a useEffect. Fixes https://github.com/twentyhq/twenty/issues/11079 Fixes https://github.com/twentyhq/core-team-issues/issues/957
This commit is contained in:
@ -38,7 +38,7 @@ export const RecordShowRightDrawerOpenRecordButton = ({
|
||||
objectNameSingular,
|
||||
recordId,
|
||||
}: RecordShowRightDrawerOpenRecordButtonProps) => {
|
||||
const record = useRecoilValue<ObjectRecord | null>(
|
||||
const record = useRecoilValue<ObjectRecord | null | undefined>(
|
||||
recordStoreFamilyState(recordId),
|
||||
);
|
||||
const { closeCommandMenu } = useCommandMenu();
|
||||
|
||||
Reference in New Issue
Block a user