Skip to content

Commit afe543c

Browse files
fix the rerender bug
Co-authored-by: Stan-l-e-y <Stan-l-e-y@users.noreply.github.com>
1 parent f33fb79 commit afe543c

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

components/home/DMessageList.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { Channel, DMChannelWithRecipient } from '@/types/dbtypes';
22
import UserIcon from '../icons/UserIcon';
33
import styles from '@/styles/Chat.module.css';
44
import { useDMChannels, useSetChannel } from '@/lib/store';
5-
import { useEffect, useState } from 'react';
65

76
function mapToComponentArray(
87
_map: Map<string, DMChannelWithRecipient>,

lib/store.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -338,10 +338,12 @@ const useDMChannelsStore = create<DMChannelsState>()((set) => ({
338338
}
339339

340340
set((state) => ({
341-
dmChannels: state.dmChannels.set(
342-
data.recipient.id,
343-
data
344-
)
341+
dmChannels: new Map(
342+
state.dmChannels.set(
343+
data.recipient.id,
344+
data
345+
)
346+
),
345347
}));
346348
},
347349

0 commit comments

Comments
 (0)