Advertisement
Guest User

Untitled

a guest
Jan 18th, 2020
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Account extends Component {
  2.     constructor(props) {
  3.         super(props);
  4.  
  5.         this.state = {
  6.             id: this.props.match.params.id,
  7.             name: '',
  8.             email: '',
  9.             password: '',
  10.             link: ''
  11.         }
  12.  
  13.     }
  14.  
  15.     componentDidMount() {
  16.  
  17.         console.log(this.state.id)
  18.  
  19.         // eslint-disable-next-line
  20.         if (this.state.id === -1) {
  21.             return
  22.         }
  23.  
  24.         ApiService.fetchAccountById(this.state.id)
  25.             .then(response => this.setState({
  26.                 item: {
  27.                     name: response.data.name,
  28.                     email: response.data.email,
  29.                     password: response.data.password,
  30.                     link: response.data.link
  31.                 }
  32.             }))
  33.  
  34.     }
  35.  
  36.     render() {
  37.  
  38.         let {name, email, password, link, id} = this.state.item;
  39.  
  40.         return (
  41.             <div>
  42.                 <h3>Account</h3>
  43.                 <div>{id}</div>
  44.                 <div>{name}</div>
  45.                 <div>{email}</div>
  46.                 <div>{password}</div>
  47.                 <div>{link}</div>
  48.             </div>
  49.         )
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement