import React from 'react' ; import { useSelector , useStore } from 'react-redux' ; import { getCommentListById } from '@app/redux/reducers/comment' ; import { loadCommentList } from '@app/redux/actions/comment' ; import CommentItem from './components/list-item' ; import TextItem from './components/text-item' ; import ListClass from '@app/class/list' ; interface Props { id : string ; query : object ; scrollLoad ? : boolean ; showPagination ? : boolean ; itemType ? : string ; postsAuthorId ? : string ; } export default function ( props ) { const { id , itemType } = props ; const store = useStore ( ) ; const list = useSelector ( ( state ) => { return getCommentListById ( state , id ) ; } ) ; return ( < ListClass { ... props } { ... list } load = { ( params ) => loadCommentList ( params ) ( store . dispatch , store . getState ) } renderItem = { ( item ) => { if ( itemType == 'text' ) { return < TextItem key = { item . _id } item = { item } / > ; } return < CommentItem comment = { item } key = { item . _id } postsAuthorId = { props . postsAuthorId || '' } / > ; } } />); }