I used visual code, and Terminal to complete this task. I assume that you have all the requirements to build a react app. Otherwise check this link: https://www.youtube.com/watch?v=9hb_0TZ_MVI
1 On OS Mac open terminal and create project called ' contactform '
change directory: cd contactform
-
In the project directory Create a react app named ' react-form ' run: npx create-react-app react-form
-
Build the app for production run:
npm run build
- In your SRC folder create a new folder called component
- In the folder component create a JS file called User.js see: https://github.com/jaimehernan95/react-js-contact-form-cloud-firestore/tree/master/src/component
- copy and paste the code from the repository
- In the folder component create a JS file called Firestore.js
style and image
-
in the SRC folder create a new folder called ' assets '.
-
In the assets folder copy and paste the folders css and img from this repository: https://github.com/jaimehernan95/react-js-contact-form-cloud-firestore/tree/master/src/assets
-
open the index.js and the following:
import './assets/css/bootstrap.min.css' import './assets/css/agency.min.css'
- open App.js and add the following after see example: https://github.com/jaimehernan95/react-js-contact-form-cloud-firestore/blob/master/src/App.js
Firebase
- Firestore.js file will contain the firebase configuration see: https://github.com/jaimehernan95/react-js-contact-form-cloud-firestore/blob/master/src/component/Firestore.js
- Create a new firebase project from https://firebase.google.com/
- In the firebase console click on your project overview
- click on + Add App
- select web </>
- new window open: Enter the name of your APP
- Click on Register APP
- A new window will display the firebase configuration
- Copy and paste the firebase configuration into your file Firestore.js ( see the repository example above)
- In the Firebase Console click on Database
- create a new collection (table) called users
- inside the collection users add 3 fields: name, email and message
- the 3 fields must be string and the value leave it empty
field: name fiel: email fiel: message type: string type: string type: string value: value: value:
- save changes
Firebase installation and Depployment
- go back to terminal and navigate to your project directory install the firebase tools globally, run:
npm install firebase-tools -g
- login to firebase console run:
firebase login
- after logged in run:
firebase init
-
select Firebase hosting with the tab and hit enter
-
select the project an existing project option
-
select your project
-
use a public directory? add the name of the projct: build and the hit enter. ' you will notice on visual code that a new project has been created'
-
public directory? build
-
select 'YEs' : configure as a single-page app index. html? YES
-
select 'NO ': file build index. htmnl overwrite? NO
-
run npm build
-
firebase deploy
-
open the web link and enter information in the contact form
-
navigate to your firebase database
-
the information entered in the contact form must be there.
Update Information on Firebase
- if you add or modify the files run the following command to see the new changes:
- npm run build
- firebase deploy
- Notes: I followed the tutorial from the link below React + Cloud Firestore: Step by step tutorial. It didn't work for me because there are some mistakes. I modified and improved a little bit. https://medium.com/get-it-working/get-googles-firestore-working-with-react-c78f198d2364
#React
This project was bootstrapped with Create React App.
In the project directory, you can run:
Runs the app in the development mode.
Open http://localhost:3000 to view it in the browser.
The page will reload if you make edits.
You will also see any lint errors in the console.
Launches the test runner in the interactive watch mode.
See the section about running tests for more information.
Builds the app for production to the build
folder.
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.
Your app is ready to be deployed!
See the section about deployment for more information.
Note: this is a one-way operation. Once you eject
, you can’t go back!
If you aren’t satisfied with the build tool and configuration choices, you can eject
at any time. This command will remove the single build dependency from your project.
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except eject
will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
You don’t have to ever use eject
. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
You can learn more in the Create React App documentation.
To learn React, check out the React documentation.
This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify