Been a long time trying to get this to work properly. This blog post will be in-depth.
Been a long time trying to get this to work properly. This blog post will be in-depth. I created an app that allows local business owners to register for an account and post announcements for their businesses. I admit it isn’t the best looking app right now but I would like to apply more styling to it in the future and add additional features, like maybe a search functionality.
The backend API was built using Ruby on Rails. When building out an API for a front-end application there are a couple of things to do. First, you have to enter this into the command line to start up a new Rails API:
rails new your_app --api
And if you want to use a database like Postgresql, you add this to the command, that way Rails knows what database it will use for your API. You can leave it blank if you choose to use SQLite instead, which is the default database Rails typically uses.
rails new your_app --api -d=postgresql
When building out your API, there are a couple modifications to the config folder. First, in the initializers folder is your cors.rb file, you’ll have to modify it to be able to use both localhost:3000 and localhost:3001. Because your front-end is rendering information from the database, they have to be connected.
Don’t forget your methods!
If you’re going to use Postgresql like I did, here is the main troubleshooting issue that I encountered and the solution to fix it.
Article covers: How native is react native?, React Native vs (Ionic, Cordova), Similarities and difference between React Native and Native App Development.
React Native Redux Example Tutorial From Scratch. We connect the React Native app to Redux store to save and retrieve the application data.
Redux is a light weighted State Management Tool that helps the components in our React App to communicate with each other. The simple concept behind this is that every state of the component is kept in a store that will be global. So that every component can access any state from that store.
How to set up a basic version of Redux in your React or React Native application. To make things clearer, I based my setup on my event application, where users create events that other users attend. We generated the action creators, reducers, and Redux store, and wrapped the application in a provider.
Redux is a powerful state management tool that can be very useful as your React or React Native application grows and requires you to keep track of more state.