Closed anaismveras closed 2 years ago
MERN
i get the gaycations from the db but i have to sign out and sign back in to get new gaycations to show in the favroites
App.js
const getGaycations = () => { if (user !== null) { axios.get('http://localhost:8000/destinations',{ headers: { "Authorization": `Bearer ${user.token}` } }) .then(foundGaycations => { console.log('this is faves', foundGaycations) setGaycations(foundGaycations) }) } } useEffect(() => { getGaycations() }, [user])
userGaycation.js
const UsersGaycations = (props) => { useEffect(() => { }, [props]) const mapGaycations = props.gaycations.map(place => { // console.log('this is place length', place.image_url) if (place.image_url.length === 31) { return ( <form> <h1>{place.city}</h1> <p>There is no image for this city</p> <input type="Submit" value="Delete Gaycation" /> </form> ) } else { return ( <form> <h1>{place.city}</h1> <img src={place.image_url} alt={place.city} /> <input type="Submit" value="Delete Gaycation"/> </form> ) } }) return ( <div> <h1>Your Gaycation Destinations:</h1> {mapGaycations} </div> ) }
no error
i am using use effect correctly?
ive trying playing around witht eh useeffect
What stack are you using?
(ex: MERN(mongoose + react), DR(django + react), PEN, etc.)
MERN
What's the problem you're trying to solve?
i get the gaycations from the db but i have to sign out and sign back in to get new gaycations to show in the favroites
Post any code you think might be relevant (one fenced block per file)
App.js
userGaycation.js
If you see an error message, post it here. If you don't, what unexpected behavior are you seeing?
no error
What is your best guess as to the source of the problem?
i am using use effect correctly?
What things have you already tried to solve the problem?
ive trying playing around witht eh useeffect