├── public ├── robots.txt ├── favicon.ico ├── logo192.png ├── logo512.png ├── manifest.json └── index.html ├── src ├── setupTests.js ├── App.test.js ├── App.js ├── index.css ├── index.js ├── firebase.js ├── App.css ├── logo.svg ├── components │ ├── ContactForm.js │ └── Contacts.js └── serviceWorker.js ├── .gitignore ├── package.json └── README.md /public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodAffection/React-CRUD-with-Firebase/HEAD/public/favicon.ico -------------------------------------------------------------------------------- /public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodAffection/React-CRUD-with-Firebase/HEAD/public/logo192.png -------------------------------------------------------------------------------- /public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodAffection/React-CRUD-with-Firebase/HEAD/public/logo512.png -------------------------------------------------------------------------------- /src/setupTests.js: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom/extend-expect'; 6 | -------------------------------------------------------------------------------- /src/App.test.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { render } from '@testing-library/react'; 3 | import App from './App'; 4 | 5 | test('renders learn react link', () => { 6 | const { getByText } = render(); 7 | const linkElement = getByText(/learn react/i); 8 | expect(linkElement).toBeInTheDocument(); 9 | }); 10 | -------------------------------------------------------------------------------- /src/App.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import logo from './logo.svg'; 3 | import './App.css'; 4 | import Contacts from './components/Contacts'; 5 | 6 | function App() { 7 | return ( 8 |
9 |
10 | 11 |
12 |
13 | ); 14 | } 15 | 16 | export default App; 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | import * as serviceWorker from './serviceWorker'; 6 | 7 | ReactDOM.render( 8 | 9 | 10 | , 11 | document.getElementById('root') 12 | ); 13 | 14 | // If you want your app to work offline and load faster, you can change 15 | // unregister() to register() below. Note this comes with some pitfalls. 16 | // Learn more about service workers: https://bit.ly/CRA-PWA 17 | serviceWorker.unregister(); 18 | -------------------------------------------------------------------------------- /src/firebase.js: -------------------------------------------------------------------------------- 1 | import * as firebase from "firebase"; 2 | 3 | var firebaseConfig = { 4 | apiKey: "AIzaSyDqY6ShKNmvMZ6SpPffjzBKc2zW6MZggzw", 5 | authDomain: "react-crud-262e5.firebaseapp.com", 6 | databaseURL: "https://react-crud-262e5.firebaseio.com", 7 | projectId: "react-crud-262e5", 8 | storageBucket: "react-crud-262e5.appspot.com", 9 | messagingSenderId: "766630761998", 10 | appId: "1:766630761998:web:eff168790dce0f0cebce5f" 11 | }; 12 | // Initialize Firebase 13 | var fireDb = firebase.initializeApp(firebaseConfig); 14 | 15 | export default fireDb.database().ref(); -------------------------------------------------------------------------------- /public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /src/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | } 4 | 5 | .App-logo { 6 | height: 40vmin; 7 | pointer-events: none; 8 | } 9 | 10 | @media (prefers-reduced-motion: no-preference) { 11 | .App-logo { 12 | animation: App-logo-spin infinite 20s linear; 13 | } 14 | } 15 | 16 | .App-header { 17 | background-color: #282c34; 18 | min-height: 100vh; 19 | display: flex; 20 | flex-direction: column; 21 | align-items: center; 22 | justify-content: center; 23 | font-size: calc(10px + 2vmin); 24 | color: white; 25 | } 26 | 27 | .App-link { 28 | color: #61dafb; 29 | } 30 | 31 | @keyframes App-logo-spin { 32 | from { 33 | transform: rotate(0deg); 34 | } 35 | to { 36 | transform: rotate(360deg); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "firebase_crud", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@testing-library/jest-dom": "^4.2.4", 7 | "@testing-library/react": "^9.3.2", 8 | "@testing-library/user-event": "^7.1.2", 9 | "firebase": "^7.14.1", 10 | "react": "^16.13.1", 11 | "react-dom": "^16.13.1", 12 | "react-scripts": "3.4.1" 13 | }, 14 | "scripts": { 15 | "start": "react-scripts start", 16 | "build": "react-scripts build", 17 | "test": "react-scripts test", 18 | "eject": "react-scripts eject" 19 | }, 20 | "eslintConfig": { 21 | "extends": "react-app" 22 | }, 23 | "browserslist": { 24 | "production": [ 25 | ">0.2%", 26 | "not dead", 27 | "not op_mini all" 28 | ], 29 | "development": [ 30 | "last 1 chrome version", 31 | "last 1 firefox version", 32 | "last 1 safari version" 33 | ] 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # React-CRUD-with-Firebase 2 | React project demonstrating CRUD Operations with Firebase. 3 | 4 | ## How it works ? 5 | 6 | :tv: Video tutorial on this same topic 7 | Url : https://youtu.be/pI4438IHBYY 8 | 9 | Video Tutorial for Complete React CRUD with Asp.Net Core Web API 12 | 13 | 14 | | :bar_chart: | List of Tutorials | | :moneybag: | Support Us | 15 | |--------------------------:|:---------------------|---|---------------------:|:-------------------------------------| 16 | | Angular |http://bit.ly/2KQN9xF | |Paypal | https://goo.gl/bPcyXW | 17 | | Asp.Net Core |http://bit.ly/30fPDMg | |Amazon Affiliate | https://geni.us/JDzpE | 18 | | React |http://bit.ly/325temF | | 19 | | Python |http://bit.ly/2ws4utg | | :point_right: | Follow Us | 20 | | Node.js |https://goo.gl/viJcFs | |Website |http://www.codaffection.com | 21 | | Asp.Net MVC |https://goo.gl/gvjUJ7 | |YouTube |https://www.youtube.com/codaffection | 22 | | Flutter |https://bit.ly/3ggmmJz| |Facebook |https://www.facebook.com/codaffection | 23 | | Web API |https://goo.gl/itVayJ | |Twitter |https://twitter.com/CodAffection | 24 | | MEAN Stack |https://goo.gl/YJPPAH | | 25 | | C# Tutorial |https://goo.gl/s1zJxo | | 26 | | Asp.Net WebForm |https://goo.gl/GXC2aJ | | 27 | | C# WinForm |https://goo.gl/vHS9Hd | | 28 | | MS SQL |https://goo.gl/MLYS9e | | 29 | | Crystal Report |https://goo.gl/5Vou7t | | 30 | | CG Exercises in C Program |https://goo.gl/qEWJCs | | 31 | -------------------------------------------------------------------------------- /src/logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 15 | 16 | 18 | 19 | 28 | React App 29 | 30 | 31 | 32 | 33 |
34 | 44 | 47 | 50 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /src/components/ContactForm.js: -------------------------------------------------------------------------------- 1 | import React, { useState, useEffect } from "react"; 2 | 3 | const ContactForm = (props) => { 4 | const initialFieldValues = { 5 | fullName: '', 6 | mobile: '', 7 | email: '', 8 | address: '' 9 | } 10 | 11 | var [values, setValues] = useState(initialFieldValues) 12 | 13 | useEffect(() => { 14 | if (props.currentId == '') 15 | setValues({ 16 | ...initialFieldValues 17 | }) 18 | else 19 | setValues({ 20 | ...props.contactObjects[props.currentId] 21 | }) 22 | }, [props.currentId, props.contactObjects]) 23 | 24 | const handleInputChange = e => { 25 | var { name, value } = e.target 26 | setValues({ 27 | ...values, 28 | [name]: value 29 | }) 30 | } 31 | const handleFormSubmit = e => { 32 | e.preventDefault(); 33 | props.addOrEdit(values) 34 | } 35 | 36 | return ( 37 |
38 |
39 |
40 |
41 | 42 |
43 |
44 | 48 |
49 |
50 |
51 |
52 |
53 | 54 |
55 |
56 | 60 |
61 |
62 |
63 |
64 | 65 |
66 |
67 | 71 |
72 |
73 |
74 |