import React, { Component } from "react";
import CommonLists from "./common_lists"
class WatcherUsers extends Component {
  componentDidMount=()=>{
    this.updateDocumentTitle();
  }

  componentDidUpdate(){
    this.updateDocumentTitle();
  }

  // 更新网页标题
  updateDocumentTitle(){
    const {user, current_user} = this.props;
    if(user && current_user){
      const {username, login} = user;
      const title_type =login === current_user.login ? "我" : "TA";
      document.title = `${title_type}的关注-${username}`
    }
  }

  render() {
    const {user, current_user , match, fetchUser} = this.props;
    return (
      user && user.login &&  
      <CommonLists 
        userType="watch_users" 
        login={user.login} 
        current_user={current_user} 
        fetchUser={fetchUser}
        match={match}
      />
    );
  }
}
export default WatcherUsers;
