Search code examples
gpsmapsreact-nativereact-native-router-flux

React-Native using Components without render


I am new to react-native and am trying to build a Map component that relies on a GPS component. (I am actually not even sure if 'component' is the correct word)

I want to render the map using a UI, but I also need the GPS to get the location information.

Now, how can I create a GPS class including all the GPS logic, calling only a single function to update the location on the page page? Or more specifically, how can I separate the GPS code into a new file without having to call a <GPSComponent /> within the render method of the map-component?

To be more specific with the code example, I put it on CodePen here https://codepen.io/yeni/pen/WOrjJx


Solution

  • Just put your GPS class in a separate file. The class should not extend Component.

    Then import your GPS class in your UI Component (e.g. import gps from './gps') and use it :)