import React from 'react' ; import { useSelector , useStore } from 'react-redux' ; import { loadMessageList } from '@app/redux/actions/message' ; import { getMessageListById } from '@app/redux/reducers/message' ; import Item from './components/list-item' ; import ListClass from '@app/class/list' ; interface Props { id : string ; query : object ; scrollLoad ? : boolean ; showPagination ? : boolean ; nothing ? : any ; } export default function ( props ) { const { id } = props ; const store = useStore ( ) ; const list = useSelector ( ( state ) => { return getMessageListById ( state , id ) ; } ) ; return ( < ListClass { ... props } { ... list } load = { ( params ) => loadMessageList ( params ) ( store . dispatch , store . getState ) } renderItem = { ( item ) => { return ( < div key = { item . _id } > { item . _create_at ? < div className = "text-center text-secondary" > { item . _create_at } < /div> : null} < Item message = { item } / > < /div>); } } renderHead = { ( { loadData } ) => { if ( list && list . more ) { return ( < div className = "text-center pt-2 pb-2" > < span className = "a" onClick = { ( ) => { loadData ( ) ; } } > 加载更多 < /span> < /div>); } else { return null ; } } } />); }