Files
watchparty/admin/src/App.jsx
T
2020-08-15 11:45:50 -04:00

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>;
}
}