The problem is that state is staying undefined. The first console log of nextProps.userid is showing the correct userid but it is not changing state and the second console log comes back null.
class Profile extends React.Component {
constructor(props) {
super(props);
this.state = {
user: this.props.userid,
};
}
componentWillReceiveProps(nextProps){
console.log('PROFILE USERID', nextProps.userid)
const userid = nextProps.userid
this.setState({user:userid})
console.log('PROFILE USERID 2', this.state.user)
}