1
0
mirror of https://github.com/ascribe/onion.git synced 2025-02-01 04:19:34 +01:00
onion/js/components/ascribe_routes/auth_component.js

33 lines
716 B
JavaScript
Raw Normal View History

2015-10-06 10:20:36 +02:00
'use strict';
import React from 'react';
import UserStore from '../../stores/user_store';
import UserActions from '../../actions/user_actions';
export function AuthComponent(Component) {
return React.createClass({
getInitialState() {
return UserStore.getState();
},
componentDidMount() {
UserStore.listen(this.onChange);
UserActions.fetchCurrentUser();
},
componentWillUnmount() {
UserStore.unlisten(this.onChange);
},
onChange(state) {
this.setState(state);
},
render() {
return (
<Component {...this.props}/>
);
}
});
}