refactor(30-01): wrap JKSessionRemoteTracks with React.memo
- Add memo to React imports (with useMemo) - Wrap component with memo(function JKSessionRemoteTracks) - Add displayName for React DevTools - Prevents unnecessary re-renders when mixerHelper and sessionModel props unchanged
This commit is contained in:
parent
4dea95e855
commit
a26f755912
|
|
@ -1,11 +1,11 @@
|
||||||
import React, { useMemo } from 'react';
|
import React, { useMemo, memo } from 'react';
|
||||||
import { useSelector } from 'react-redux';
|
import { useSelector } from 'react-redux';
|
||||||
import { selectActiveSession } from '../../store/features/activeSessionSlice';
|
import { selectActiveSession } from '../../store/features/activeSessionSlice';
|
||||||
import { useAuth } from '../../context/UserAuth';
|
import { useAuth } from '../../context/UserAuth';
|
||||||
import JKSessionAudioInputs from './JKSessionAudioInputs';
|
import JKSessionAudioInputs from './JKSessionAudioInputs';
|
||||||
import { getAvatarUrl, getInstrumentIcon45_inverted } from '../../helpers/utils';
|
import { getAvatarUrl, getInstrumentIcon45_inverted } from '../../helpers/utils';
|
||||||
|
|
||||||
const JKSessionRemoteTracks = ({ mixerHelper, sessionModel }) => {
|
const JKSessionRemoteTracks = memo(function JKSessionRemoteTracks({ mixerHelper, sessionModel }) {
|
||||||
// Phase 4: Replace CurrentSessionContext with Redux
|
// Phase 4: Replace CurrentSessionContext with Redux
|
||||||
const currentSession = useSelector(selectActiveSession);
|
const currentSession = useSelector(selectActiveSession);
|
||||||
const { currentUser } = useAuth();
|
const { currentUser } = useAuth();
|
||||||
|
|
@ -74,6 +74,8 @@ const JKSessionRemoteTracks = ({ mixerHelper, sessionModel }) => {
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
});
|
||||||
|
|
||||||
|
JKSessionRemoteTracks.displayName = 'JKSessionRemoteTracks';
|
||||||
|
|
||||||
export default JKSessionRemoteTracks;
|
export default JKSessionRemoteTracks;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue