react-map-gl-geocoder
react-map-gl-geocoder copied to clipboard
How to get the current value?
Is there any way to keep the current value of Geocoder on the state?
For example, creating a hook like setSearchQuery(Geocoder.input.current.value) ?
This is my Geocoder:
<Geocoder
mapRef={mapRef}
containerRef={geocoderContainerRef}
mapboxApiAccessToken={token}
onViewportChange={handleGeocoderViewportChange}
placeholder=""
position="top-left"
minLength={4}
limit={3}
trackProximity
marker={false}
enableEventLogging={false}
/>
Thanks!
Hey @gmsy, you can use the onResult prop and cache the value of each query result. If you want to cache the value as the user is typing, you can use the onLoading prop. You'll probably actually need to use both.
Thanks for your reply, @SamSamskies . Do you think there is also a way maybe to change styling for the Geocoder input only when the Geocoder input is focused?
You'll have to hack it by importing styles with higher specificity for the styles that you want to override.