import React from 'react' ; import { useSelector , useStore } from 'react-redux' ; import { loadPostsList } from '@app/redux/actions/posts' ; import { getPostsListById } from '@app/redux/reducers/posts' ; import ItemRich from './components/item-rich' ; import ItemPoor from './components/item-poor' ; import ListClass from '@app/class/list' ; interface Props { id : string ; query : object ; scrollLoad ? : boolean ; showPagination ? : boolean ; itemType ? : string ; nothing ? : string ; } export default function ( props ) { const { id , itemType } = props ; const store = useStore ( ) ; const list = useSelector ( ( state ) => { return getPostsListById ( state , id ) ; } ) ; return ( < ListClass { ... props } { ... list } load = { ( params ) => loadPostsList ( params ) ( store . dispatch , store . getState ) } renderItem = { ( item ) => { if ( itemType == 'poor' ) { return ( < ItemPoor key = { item . _id } posts = { item } / > ) ; } return ( < ItemRich key = { item . _id } posts = { item } / > ) ; } } />); }