Switching to @Radium decorator

This commit is contained in:
John Lyon-Smith
2018-03-22 15:27:12 -07:00
parent 06ae76047e
commit 1b35ac8b22
32 changed files with 115 additions and 122 deletions

View File

@@ -9,8 +9,8 @@ import logoImage from 'images/logo.png'
import { versionInfo } from './version'
import { sizeInfo, colorInfo } from 'ui/style'
import { api } from 'src/API'
import { reactAutoBind } from 'auto-bind2'
import PropTypes from 'prop-types'
import autobind from 'autobind-decorator'
export class App extends Component {
static propTypes = {
@@ -19,16 +19,11 @@ export class App extends Component {
constructor(props) {
super(props)
reactAutoBind(this)
this.state = {
loggedInUser: api.loggedInUser
}
}
handleUpdate() {
this.setState({ loggedInUser: api.loggedInUser })
}
componentDidMount() {
api.addListener('login', this.handleUpdate)
api.addListener('logout', this.handleUpdate)
@@ -39,6 +34,11 @@ export class App extends Component {
api.removeListener('logout', this.handleUpdate)
}
@autobind
handleUpdate() {
this.setState({ loggedInUser: api.loggedInUser })
}
handleLogout() {
// We have to use window here because App does not have history in it's props
window.location.replace('/logout')
@@ -52,6 +52,7 @@ export class App extends Component {
window.location.replace('/profile')
}
@autobind
handleChangeTitle(title) {
this.setState({ title })
}