React native connecting to a sql database - reactjs

I need someone to point me to the right direction, i am playing around with SQL databases and wish to connect the dots with react native. how do i get react native user input to update a database value for example.
if anyone can point me in the right direction please

So typically react native doesnt directly communicate with an sql database, the backend does, this is for many reasons, mainly security. If you want to avoid building a backend, you should look into Firebase. Other than that, you can use SQLLite on react native, but you'll only be able to store locally
To answer your question, you'll probably want to create a simple REST Api backend to communicate with your app. The backend will update the database, not the app.

Related

MongoDB with Expo React Native

I have been trying to figure out which database to use with my React Native project (using Expo). I need online capabilities eventually, but would prefer to develop locally. I was initially looking at MongoDB/Realm, but both appear to not support expo. Is this correct? Or is there a way to use MongoDB with React Native and Expo?
i think you can use whatever database you like by connecting to it through a REST API using fetch in your react native project, in case you want to implement offline and realtime capabilities i suggest you take a look to firestore or realtime database

Should I call from server or client if data is already on client side?

I feel this is a stupid question, but I am having a problem answering it myself, so I am relying on experienced programmers to help me with this.
I have a react app that is running on a laravel backend (php), and using redux for a presisted state for my app.
I essentially request all data that will be present on another page, and would like to know, if I should just use the data that I initially have in my redux store or just reload everything on a different page?
You should use the data in redux store. But persisted data can be altered, so in case you want to verify the data or something along the lines, you can just compare the data that is on the client side with that on the server. Otherwise, the very idea of redux is to use data in multiple pages (components)

Is there a "Best Practices" on designing an application written both in React and React-Native?

We are looking to make a web-based React application because its target user base happens to be predominantly PC users. We expect the user base will change towards smaller screens, i.e. tablets users.
The development team here isn't experienced in React-Native apps, but the first impression here is that there are differences in function calls. So, we are wondering if there is a "Best Practices" to designing and coding a React application running as native and web. More to the point, are there common practices in which a native and web React application can share a significant amount of code base?
Generally, you can share a lot of business logic between react native and web applications. By business logic, I basically mean the logic in your app that aren't components. Trying to share components is pretty hard, since the base level components are different (View vs div, etc), and you generally want things structured pretty differently on the web vs a mobile app.
If you are using redux or something like it to manage your app's state, you could share the reducers, action creators, api calls, etc. You would put all of that into a shared package, and then both the web and native apps would import them and use them as needed. I wouldn't go this route until it is clear you need an app. It would be easy enough to extract at a later date when it is necessary.
If you're using graphql, you benefit from the fact that a lot of the shared logic is encoded in the schema. Your mobile app can query the same graphql server and get the same data or include more/less fields depending on what is necessary for the mobile app to function.

Practical approach for design a todo-app

I try to make a todo-app using react/(maybe)redux. My goal is to have a client that cant communicate with server using RESTful API to fetch and update data.
I already wrote my server that can handle AJAX request and host it on heroku.
My next step is to create a front-end using react or react/redux. Im not sure what is the right approach to store and update data.
Should I fetch and update data directly from client to server? If this the case, I think I only need to use react, do I ?
The second approach, I guess I need to use react and redux, is to fetch the "initial" data from server and store in reducers, display and change whatever user wants. Then, at the end, update the data back to server.
Im still learning web dev. I really appreciate any suggestion or documents that I can read
React alone will be plenty sufficient for a small app. As a rule, adding redux adds complexity and it is best used when many containers need to access the same state.

Do we need to persist redux store data while creating mobile apps with react native?

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.

Resources