1
0
mirror of https://github.com/ascribe/onion.git synced 2024-06-30 21:52:08 +02:00
onion/js/components/edition_container.js
2015-06-01 18:59:47 +02:00

52 lines
1.3 KiB
JavaScript

import React from 'react';
import EditionActions from '../actions/edition_actions';
import EditionStore from '../stores/edition_store';
import UserActions from '../actions/user_actions';
import UserStore from '../stores/user_store';
import Edition from './edition';
/**
* This is the component that implements resource/data specific functionality
*/
let EditionContainer = React.createClass({
getInitialState() {
return {'user': UserStore.getState(),
'edition': EditionStore.getState()}
},
onChange(state) {
this.setState(state);
},
componentDidMount() {
EditionActions.fetchOne(this.props.params.editionId);
EditionStore.listen(this.onChange);
UserActions.fetchCurrentUser();
UserStore.listen(this.onChange);
},
componentDidUnmount() {
EditionStore.unlisten(this.onChange);
UserStore.unlisten(this.onChange);
},
render() {
if('title' in this.state.edition) {
return (
<Edition edition={this.state.edition } currentUser={this.state.currentUser}></Edition>
);
} else {
return (
<p>Loading</p>
);
}
}
});
export default EditionContainer;