So to use the data we're getting back from the map screen, we can go directly to the location picker
component because there, I do have access to props navigation since I feed this in there from the new
place screen, so I can directly listen to changes in my params there and there,
let's say at the top of the component, here where I set up my state, I can also get my picked location
with the help of props.navigation.getParam and now extract the param I'm setting in the map screen,
so that picked location param I'm setting there, that's what we can retrieve here.
Now of course, this will not always be set,
for example if we go to the new place screen from our places list screen, there in this navigation action,
I'm not setting any param so therefore of course this is not always available but in that case picked
location will just be undefined.
Now here, I now would have a name clash because I have this picked location or this picked location here
and actually, I kind of want to merge both together.
So what I'll do here, I'll rename this to map picked location and then add use effect here to the location
picker and in the end, check for whenever this changes.
So here, I'll add use effect and in this effect here, I want to trigger it or I want to run this
effect whenever map pick location changes and if I then do have a map pick location, so if this is
defined, I'll call set picked location to use my internal state here and set this to the location that
was picked on the map.
So this is now an elegant way of storing the location we picked on the map and which we passed around
with props in our internal location picker state here.
Now we'll update the pick location to the location picked on the map and therefore hopefully we see it in
the preview. If we go back there and open the map and then I pick a location here somewhere around
this hospital let's say and I click save,
indeed we see that here on this preview and the same should be the case on Android
and even if I fetch a user location first which is at the Googleplex, if I then pick a location here
somewhere in San Francisco and I save this,
this gets updated here in the preview as well.
So that works,
this is how we can pick places on the map and use them here in the preview and of course also therefore
kind of store them here in the location picker.
Now we also need to make sure we can pass the data from the location picker back to the new place screen
because that's ultimately where we need that data.