Coder Social home page Coder Social logo

react-firebase-steps's Introduction

React/Firebase/ReactStrap/Sass

Look for multiple steps in different branches.

  1. Firebase: setup
  2. Postman: add sample data
  3. App: add login/logout (modify sample data to match uid)
  4. App: get data
  5. App: post data
  6. App: delete data
  7. App: update data

Project Setup

  1. This project was bootstrapped with Create React App.
  2. Once you download the project, run npm install in the project directory.

Firebase Setup

  1. Create a Firebase Realtime Database.
  2. Setup Database Rules
{
"rules": {
  ".read": true,
  ".write": true,
    "boards": {
      ".indexOn": ["uid"]
    },
    "pins": {
      ".indexOn": ["boardId", "uid"]
    }
  }
}
  1. Setup Authentication/ Sign-in Method - start with Google.
  2. Use Postman to add sample data.
  3. Create config.js with your projects credentials. (helpers/data/config.js)

Firebase Flow

  • When the App loads up, it should check for firebase and if not found initialize the app with firebase. (helpers/data/connection). This happens before anything else.

    fbConnection();
  • Within App.js setup a function to listen for when a user logs in or out.

     authListener = () => firebase.auth().onAuthStateChanged((user) => {
      if (user) {
        this.setState({ authed: true });
      } else {
        this.setState({ authed: false });
      }
    });
  • componentDidMount() should invoke authListener()

  • Create a function loadComponent to determine what to show (full app or login)

  • render() invokes loadComponent and pass the state of authed to the <MyNavbar authed={authed} /> . This gives ability to show login or logout in the navbar.

NPM Available Scripts

In the project directory, you can run:

npm start

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.

npm test

npm run build

npm run eject

Note: this is a one-way operation. Once you eject, you can’t go back!

react-firebase-steps's People

Contributors

jquinsmith avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.