title: react-google-maps/api Avoiding re-render of Map after some state changes
body: <p>I was having problems where my GoogleMaps instance would refresh and self center itself on some <code>onClick</code> function where the state was being set and the entire Component rendering cycle would happen.</p>
  <p>After some Googling it was suggested that the component instantiation be separated and re-used. The problem now is I have some logic to display markers inside <code>&lt;GoogleMaps&gt;</code> component that is no longer working as expected and I don't know how to refactor:</p>
  <pre><code>export default function LocationSearchResults({
      ...
      }) {
      const [map, setMap] = useState(null)
      const [markersContainer, setMarkersContainer] = useState([])
  
      const getMap = () =&gt; {
  
          if (map) {
              return map;
          } else {
              setMap(&lt;GoogleMap mapContainerStyle={containerStyle}
                  options={ {
                          minZoom: 3,
                          maxZoom: 15
                      }}
                  center={{
                          lat: 49.25,
                          lng: -84.5
                      }}
                  zoom={5}
                  onLoad={onLoad}
                  onDragEnd={onDragEnd} &gt;
                  {
                      markersContainer.map(place =&gt; { //Only executes once? Does not listen for changes
                          return (&lt; Marker key={place.id}
                              position={ place.position}
                          /&gt;
                          )
                      })
  
                  }
  
                  &lt;/GoogleMap&gt;
  
                  )
  
                  return map
  
              }
          }
  
          render( &lt;div className=&quot;...&quot; &gt;
                      {
                       getMap()
                      } 
              &lt;/div&gt;
          )
      }
  </code></pre>
  <p>I don't have a ton of experience with React, any help is appreciated thanks!</p>