I want to try making an application for location sharing with my friends.
Is it possible using react native geolocation API and firebase?
If not what other approach can i follow?
You can use Geolocation of ReactNative.
https://facebook.github.io/react-native/docs/geolocation.html#watchposition
Check the watchPosition method, it registers a callback which invokes whenever your location changes, and you will receive a position object.
You should then send this data to firebase.
On all your devices, you should use a listener to listen for changes in your firebase cloud firestore.
https://firebase.google.com/docs/firestore/query-data/listen
Display the location data on your app.
Related
I have a react application that needs read configuration JSON from remote API before rendering. I intend to store the configuration data in local or session storage for access after the app is mounted.
I tried to fetch the remote data in the html header using javascript and store it in session storage, but the react component doesn't get the data every time, it seems the app is rendered before the configuration data is stored in session storage.
Any help or suggestion is appreciated!
If sounds like you need to wrap your application in a HOC which will take care of checking for previously downloaded config in session storage, or download it if it's not there. This component should show a loading state until you have what you need, to use the application.
I have a react app and I would like to implement something like a debugging component that can change data/toggles on the app that is accessible on each page, floating rather than integral to the page.
I made a POC that was integrated into one page, but I'm wanting to make it more mobile and agnostic.
How would one go about this?
I'm running a local express dev server to push mock data and initially I was specifying the mock data pushing that info with a login form push, but since refactoring I am struggling to think of how to persist the data, especially if I refresh the page?
You must save your data in localStorage,everytime your component start you load your data, if you havent your data load from server.
Finally you can use useContext to access data through all application.
localStorage will work as cache data: https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage
useContext to accessData: https://reactjs.org/docs/context.html
on project we have need use architecture, where getting data from API display on screens and storage in locale state. How this architecture implementing on React Native with using state managment libraries.
P.S. For data, with getting from API, we cannot be used global state.
You could try using React-Query for fetching data and React.Context for storing and providing data to children.
For a persistent storage you can use AsyncStorage
I have a use case where I want to open a react application in new window whenever user clicks a button. I want to pass some props to the react application. Presently I am sending the props via appending them to URL.
Example
Let's say my application is accessible at lomoto/car. I am currently sending parameters via lomoto/car/value1/value2. I am accessing these properties via props.match.params.prop1 and props.match.params.prop2. I am using react-router v4 for routing.
Is there any other recommended way of achieving this?
You can save the state to the browser's local storage and then access it from any tab.
In this egg head video Dan Abramov explains how to make use of the browser's local storage for redux.
You can use a similar approach with or without redux.
While creating apps with reactJS we need to persist the redux state data, because the store gets reinitialized when the browser is refreshed. Is this scenario applicable while creating mobile apps? I mean the mobile apps cannot be refreshed right?
So, while creating mobile apps with react native we need not have to bother about persisting the data fearing that the app will be refreshed? Please correct me if I'am wrong
Just like on desktop applications, your application can be closed, the device can restart, etc, and everything not persisted goes away.
You should store anything you don't want to lose in AsyncStorage or similar.
React-Native Redux can only persists data till application has terminated. You need to store require data in Asynchronous storage or can pull data from your server using APIs.