I'm a beginner to development and I'm getting Undefined is not an object error. What am I doing wrong here? When I console log placeID it returns value, but selectedPlace returns undefined. Thanks.
const PlaceDetailScreen = props => {
const [places, setPlaces] = useState([])
useEffect(() => {
const getPlaces = async () => {
const result = await axios.get('https://tgr-admin.appspot.com/api/places')
setPlaces(result.data)
}
getPlaces()
}, [])
const placeID = props.navigation.getParam('placeId')
const selectedPlace = places.find(place => place._id === placeID)
return (
<ScrollView>
<Image source={{ uri: selectedPlace.image }} style={styles.image} />
</ScrollView>
)
}