Closed RitaHC closed 1 year ago
Do a console.log for user and not props since it looks like you destructured it. Also it looks like you are destructuring props twice here.
1) Corrected and destructured just once 2) console logged the user
CODE
const { msgAlert, user, setUser } = props;
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const [passwordConfirmation, setPasswordConfirmation] = useState('');
const [name, setName] = useState('');
const [profilePicture, setProfilePicture] = useState('');
const [coverPicture, setCoverPicture] = useState('');
const [description, setDescription] = useState('');
const [active, setActive] = useState(false);
const navigate = useNavigate();
console.log(`UPDATE PAGE user`, user)
STILL SAME - NULL
Make sure you are passing in user
into your update component. Where is user coming from?
It is coming from ShowProfile
import React from 'react'
// Import API Call
import { userProfile } from '../../api/auth'
import { useState, useEffect } from 'react'
import { Card, Container, Button } from "react-bootstrap"
import LoadingScreen from '../shared/LoadingScreen'
import ListGroup from 'react-bootstrap/ListGroup'
import Update from './Update'
const ShowProfile = (props) => {
// Define user
const { user } = props
console.log(`---------- USER PROP ---------`,props)
// // console.log(`User Name`, user.name)
if(!user){
return <p> <LoadingScreen /> </p>
}
return (
<div>
<Card>
User Profile
{user._id}
<Card.Img id='imagecover' variant="top" src={user.coverPicture} />
<Card style={{ width: '18rem' }}>
<Card.Img variant="top" src={user.profilePicture} />
<Card.Body>
<Card.Title>{user.name}</Card.Title>
<Card.Text>
{user.description}
</Card.Text>
</Card.Body>
<ListGroup className="list-group-flush">
<ListGroup.Item>Location: {user.city}</ListGroup.Item>
<ListGroup.Item>Dapibus ac facilisis in</ListGroup.Item>
<ListGroup.Item>Vestibulum at eros</ListGroup.Item>
</ListGroup>
<Card.Body>
<Card.Link href={`/update/${user._id}`}><Button>Update Details</Button></Card.Link>
<Card.Link href="#">Another Link</Card.Link>
</Card.Body>
<Update user={user}/>
</Card>
</Card>
</div>
)
}
Do you get the user information showing on this page?
Yes, getting it there
I tried removing it from the Show page and passed it in the app.js as a prop
But it not working. Could we get on a quick call to check that, I'm sure you'll get it in a sec
Issue Resolved:
THANK YOUUUUUUU ASHLEYYYYYYYY
Below is the corrected code
Bootstrap issue
<Link to={`/update/${user._id}`}>Update Details</Link> <br />
Describe the bug A clear and concise description of what the bug is.
I'm unable ti import user and its propertied as a prop on the update page. It shows props are null
What is the problem you are trying to solve?
Trying to use the user as a prop to auto fill the form
Expected behavior A clear and concise description of what you expected to happen.
when props are console logged, the user appears
What is the actual behavior? A clear and concise description of what actually happened.
Props = null
Post any code you think might be relevant (one fenced block per file) BACKEND CALL
FRONTEND
What is your best guess as to the source of the problem?
props not getting transfereed, though on the screen the url is corrctely visible and we are at the correct page
What things have you already tried to solve the problem?
Self, Online, Team work all. Stuck since yesterday
Additional context Add any other context about the problem here.
Paste a link to your repository here FrontEnd https://github.com/RitaHC/Social-Media-Clone-Front-End/tree/userF