I want all the callouts for all the markers to be opened upon mounting the screen component. Currently, it only opens only when it's clicked on the marker. How do I use useRef in a functional component to do this?
const markerRef = useRef(React.createRef)
return (
<View style={styles.container}>
<MapView
style={{ flex: 1 }}
region={region}
onRegionChangeComplete={onRegionChangeComplete}
>
{data && data.posts.map(marker => (
<Marker
ref={markerRef}
key={marker.id}
coordinate={{latitude: marker.latitude, longitude: marker.longitude }}
>
<Callout>
<Text>{marker.title}</Text>
<Text>{JSON.stringify(marker.price)}</Text>
</Callout>
</Marker>
))}
</MapView>
<View style={styles.inputContainer}>
<Icon name="magnify" size={30} color="lightgrey" />
<TextInput
placeholder="Search Term"
style={styles.input}
onChangeText={setSearch}
value={search}
returnKeyType="search"
onSubmitEditing={handleSubmit}
/>
</View>
</View>
When I console.log(markerRef.current), it doesn't provide the showCallout() method.