Summary
I have this component that reverses transcription and then renders them, it works perfectly locally by showing the list in the reverse order. But when I do yarn build and yarn start this is how it works.
- It shows the list in a not reversed order.
- Then after sometime shows the list in the reverse order.
I am using nextjs 13, and this happens only when I generate and run a build.
This is how the code rendering the transcriptions looks like.
type Props = {
transcriptions: Transcription[]
currentTranscription: string
isAdminView?: boolean
}
const TranscriptionsComponent: React.FC<Props> = ({
transcriptions,
currentTranscription,
isAdminView = false,
}) => {
const reversedTranscriptions = useMemo(
() => [...transcriptions].reverse(),
[transcriptions],
)
return (
<div className="dashboard-inner">
<div className="dashboard-inner-header">Transcript</div>
<div className="transcriptions-card-wrap">
{!isAdminView && (
<SessionTranscriptLoadingCard text={currentTranscription} />
)}
<Transcriptions transcriptions={transcriptions} />
{reversedTranscriptions
.filter((transcription) => transcription.text !== '')
.map((transcription) => (
<SessionTranscriptCard
key={transcription._id}
text={transcription.text}
time={transcription.time}
sentimentType={transcription.sentimentType}
/>
))}
</div>
</div>
)
}