tkh44 / react-geolocation

🌎🛰 Declarative geolocation for React

Home Page:https://tkh44.github.io/react-geolocation/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

excuse me ,how could I use the data from the react-geolocation

Answerhua opened this issue · comments

Hello, I am a react novice. I wonder that how could I use the data from the react-geolocation but not just
display data to the screen.

I am sorry to bother you.
Thank you very much

You can study React Components, Props and State: https://facebook.github.io/react-vr/docs/components-props-and-state.html

And then pass the data to your own components via props. Something like this...

          <Geolocation
            render={({
              position: { coords: { latitude, longitude } = {} } = {}
            }) => (
              <div>
                <MyMap latitude={latitude} longitude={longitude} />
              </div>
            )}
          />

Then in your MyMap component, you'll have full access to the data and do whatever you please!

I've used https://github.com/PaulLeCam/react-leaflet in the past and liked it.