forked from prescottprue/react-redux-firebase
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
33 lines (27 loc) · 684 Bytes
/
Copy pathApp.js
File metadata and controls
33 lines (27 loc) · 684 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { connect } from 'react-redux'
import { isLoaded, isEmpty, pathToJS } from 'react-redux-firebase'
import TodosView from './Todos'
import LoginView from './Todos'
class App extends Component {
static propTypes = {
auth: PropTypes.object
}
render () {
const { auth } = this.props
// handle initial loading of auth
if (!isLoaded(auth)) {
return <div>Loading...</div>
}
if (isEmpty(auth)) {
return <LoginView />
}
return <TodosView auth={auth} />
}
}
export default connect(
({ firebase }) => ({
auth: pathToJS(firebase, 'auth')
})
)(App)