Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get the current value? #128

Open
gmsy opened this issue Nov 7, 2021 · 3 comments
Open

How to get the current value? #128

gmsy opened this issue Nov 7, 2021 · 3 comments

Comments

@gmsy
Copy link

gmsy commented Nov 7, 2021

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!

@SamSamskies
Copy link
Owner

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.

@gmsy
Copy link
Author

gmsy commented Nov 7, 2021

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?

@SamSamskies
Copy link
Owner

You'll have to hack it by importing styles with higher specificity for the styles that you want to override.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants