29 lines
699 B
React
29 lines
699 B
React
import React from 'react';
|
|
import { Component } from 'react';
|
|
import Login from './Login';
|
|
import Dashboard from './Dashboard';
|
|
import firebase from 'firebase/app';
|
|
import 'firebase/auth';
|
|
|
|
export default class App extends Component {
|
|
constructor(props) {
|
|
super(props);
|
|
this.state = {
|
|
auth: false,
|
|
};
|
|
}
|
|
componentDidMount() {
|
|
firebase.auth().onAuthStateChanged((authUser) => {
|
|
if (authUser && !authUser.isAnonymous) {
|
|
this.setState({ auth: true });
|
|
} else {
|
|
this.setState({ auth: false });
|
|
}
|
|
});
|
|
}
|
|
render() {
|
|
const { auth } = this.state;
|
|
return <div className="app-wrapper">{auth ? <Dashboard /> : <Login />}</div>;
|
|
}
|
|
}
|