@@ -8,23 +8,29 @@ import { currentVideoTimeState } from '@store/currentVideoTime.store';
88import { feedbackBoxStyle , fbTextAreaStyle , fbStartTimeStyle } from './FeedbackItem.style' ;
99
1010import { FeedbackItemType } from '@customType/feedback' ;
11+ import { mmssFormatter } from '@utils/common.util' ;
12+ import { ONE_SECOND } from '@constants/time.constant' ;
1113
12- interface PropsType {
14+ export interface Props {
1315 feedback : FeedbackItemType ;
1416 //TODO ref type any
1517 feedbackRef : React . MutableRefObject < any [ ] > ;
1618 index : number ;
1719 editableBtns : React . ReactNode ;
1820}
19- const FeedbackItem = ( { feedback, feedbackRef, index, editableBtns } : PropsType ) => {
21+ const FeedbackItem = ( { feedback, feedbackRef, index, editableBtns } : Props ) => {
2022 const textareaRef = useRef < HTMLTextAreaElement > ( null ) ;
2123 const isFbSync = useRecoilValue ( isFbSyncState ) ;
2224 const setIsFbClicked = useSetRecoilState ( isFbClickedState ) ;
2325 const setCurrentVideoTime = useSetRecoilState ( currentVideoTimeState ) ;
2426 const { handleFbChange } = useCrudFeedback ( feedback . id ) ;
2527
2628 useEffect ( ( ) => {
27- feedbackRef . current [ index ] . style . height = textareaRef . current . scrollHeight + 'px' ;
29+ const effect = ( ) => {
30+ if ( ! feedbackRef ) return ;
31+ feedbackRef . current [ index ] . style . height = textareaRef . current . scrollHeight + 'px' ;
32+ } ;
33+ effect ( ) ;
2834 } ) ;
2935
3036 const { startTime, isFirst, content, readOnly } = feedback ;
@@ -35,10 +41,15 @@ const FeedbackItem = ({ feedback, feedbackRef, index, editableBtns }: PropsType)
3541 setCurrentVideoTime ( startTime ) ;
3642 } ;
3743
44+ const getFbRef = ( el ) => {
45+ if ( ! feedbackRef ) return ;
46+ return ( feedbackRef . current [ index ] = el ) ;
47+ } ;
48+
3849 return (
39- < div ref = { ( el ) => ( feedbackRef . current [ index ] = el ) } css = { feedbackBoxStyle } >
50+ < div ref = { getFbRef } css = { feedbackBoxStyle } >
4051 < div css = { fbStartTimeStyle } style = { { visibility : isFirst ? 'visible' : 'hidden' } } >
41- { startTime }
52+ { mmssFormatter ( startTime * ONE_SECOND ) }
4253 </ div >
4354 < textarea
4455 ref = { textareaRef }
0 commit comments