componentDidMount() { firebaseApp.database().ref().child('lastest').on('value', (snapshot) => { this.props.dispatch(showPaperList(snapshot.val())) }) }
constructor(props) { super(props); this.addNote = this.addNote.bind(this); this.removeNote = this.removeNote.bind(this); // 1. connect to firebase this.app = firebase.initializeApp(fire_config); this.database = this.app.database().ref().child('notes'); this.state = { notes: [] } }
const Home = () => { return ( <> <h1>Home</h1> <button onClick={() => app.auth().signOut()}>Sign out</button> </> ); }
// Your App Code constructor(props) { super(props) var myFirebaseRef = firebaseApp .database() .ref(); this.itemsRef = myFirebaseRef.child('items'); this.state = { newTodo: '', todoSource: new ListView.DataSource({ rowHasChanged: (row1, row2) => row1 !== row2 }) }; this.items = []; }
constructor(config) { this.connection; try { this.connection = firebase.app().database(); } catch(e) { this.connection = firebase.initializeApp(config).database(); } this.storage = new Storage(firebase.storage()); this.auth = new Auth(); this.user = new User(this.connection, this.storage); this.movie = new Movie(this.connection, this.storage); this.review = new Review(this.connection, this.storage); }
const AuthProvider = ({ children }) => { const [currentUser, setCurrentUser] = useState(null); const [pending, setPending] = useState(true); useEffect(() => { app.auth().onAuthStateChanged((user) => { setCurrentUser(user) setPending(false) }); }, []); if(pending){ return <>Loading...</> } return ( <AuthContext.Provider value={{ currentUser }} > {children} </AuthContext.Provider> ); }
try { await app .auth() .createUserWithEmailAndPassword(email.value, password.value); history.push("/");
firebase.initializeApp(configs.firebase); this.setState({ isFirebaseInitialized: true,
try { await app .auth() .signInWithEmailAndPassword(email.value, password.value); history.push("/");