import React,{useEffect,useState} from 'react';
import {Link} from 'react-router-dom';
import Nodata from '../Nodata';

export default (({ memos , selectKey })=>{
  const [list, setList] = useState(undefined);
  const [ keys , setKeys ] = useState(undefined);

  useEffect(() => {
    if (memos) {
      setList(memos);
      setKeys(selectKey[0]);
    }
  }, [memos , selectKey]);
  return(
    <ul className="BestUl">
      {
        list && list.length>0 ? list.map((item,key)=>{
          return(
          <li className="task-hide"><Link to={`/forums/${item && item.id}/detail`}>{item && item.subject}</Link></li>
          )
        }):
        <Nodata _html={`暂无${keys === "hot" ? "话题":"推荐"}~`} />
      }
    </ul>
  )
})