avoid render state updates on account switch
This commit is contained in:
@@ -24,8 +24,10 @@ export const TenderDetailModal = () => {
|
||||
useEffect(()=>{setActiveTab(activeTenderDetail?.preparationTarget ? 'pdf_stamp' : 'details');},[activeTenderDetail?.id,activeTenderDetail?.preparationTarget]);
|
||||
const noteOwner = authUser?.email || '';
|
||||
const [noteDrafts, setNoteDrafts] = useState(() => ({ owner: noteOwner, drafts: {} }));
|
||||
// Discard private drafts on account changes, before rendering another account.
|
||||
if (noteDrafts.owner !== noteOwner) setNoteDrafts({ owner: noteOwner, drafts: {} });
|
||||
// Discard private drafts after an account change without updating state during render.
|
||||
useEffect(() => {
|
||||
if (noteDrafts.owner !== noteOwner) setNoteDrafts({ owner: noteOwner, drafts: {} });
|
||||
}, [noteOwner, noteDrafts.owner]);
|
||||
const noteKey = tenderStateKey(activeTenderDetail);
|
||||
const noteDraft = noteDrafts.owner === noteOwner ? noteDrafts.drafts[noteKey] : undefined;
|
||||
const noteText = noteDraft?.text || '';
|
||||
|
||||
Reference in New Issue
Block a user