Component life cycle not rendering any data or picture

hi can anyone explain why the pictures and details not rendering.

import React from 'react';
import { fetchUserData, cancelFetch } from './dataFetcher';
import { Userlist } from './Userlist';

export class Profile extends React.Component {
  constructor(props){
      super(props);
      this.state = { userData: null };
  }

  loadUserData() {
    this.setState = ({ userData: null });
    this.fetchID = fetchUserData(this.props.username, (userData) => {
    this.setState({ userData });
});
  }

  componentDidMount() {
    this.loadUserData();
  }

  componentWillUnmount() {
    cancelFetch(this.fetchID);
  }

  componentDidUpdate(prevProps) {
    if (this.props.username !== prevProps.username) {
      cancelFetch(this.fetch.ID)
      this.loadUserData();
    }
  } 

  render() {
    const isLoading = this.state.userData === null ? true : false;
    const name = isLoading ? 'Loading...' : this.state.userData.name;
    const bio = isLoading ? 'Bio goes here' : this.state.userData.bio;
    const friends = isLoading ? [] : this.state.userData.friends;

    let className = 'Profile';
    if (isLoading) {
      className += ' loading';
    }

    return (
      <div className={className}>
        <div className="profile-picture">
          {!isLoading && ( 
            <img src={this.state.userData.profilePictureUrl} alt="" />
          )}
        </div>
        <div className="profile-body">
          <h2>{name}</h2>
          <h3>@{this.props.username}</h3>
          <p>{bio}</p>
          <h3>My friends</h3>
          <Userlist usernames={friends} onChoose={this.props.onChoose} />
        </div>
      </div>
    );
  }
}

Double check your loadUserData() method. You’re using this.setState() correctly in one spot, but not the other.

Click here for another hint and details

You’re accidentally replacing the this.setState() method with an object by using the =

If you checked the console for errors, it probably would say something to the effect of this.setState isn’t a function when this.setState() is used in the arrow function you pass to fetchUserData().

:slightly_smiling_face:

thanks always missing sumat