1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-22 09:23:13 +01:00

refactor to use AltContainer to start developing the new table component

This commit is contained in:
Tim Daubenschütz 2015-05-20 11:32:56 +02:00
parent 148b019ff9
commit ba71bd5788
2 changed files with 7 additions and 21 deletions

View File

@ -1,38 +1,24 @@
import React from 'react';
import Router from 'react-router';
import AltContainer from 'alt/AltContainer';
import PieceListStore from '../stores/piece_list_store';
import PieceListActions from '../actions/piece_list_actions';
import Table from './table';
let Link = Router.Link;
let PieceList = React.createClass({
getInitialState() {
return PieceListStore.getState();
},
componentDidMount() {
PieceListStore.listen(this.onChange);
PieceListActions.fetchPieceList();
},
componentWillUnmount() {
PieceListStore.unlisten(this.onChange);
},
onChange(state) {
this.setState(state);
},
render() {
return (
<ul>
{this.state.pieceList.map((piece, i) => {
return (
<li key={i}><Link to="piece" params={{'bitcoin_ID_noPrefix': piece.bitcoin_ID_noPrefix}}>{piece.title}</Link></li>
);
})}
</ul>
<AltContainer store={PieceListStore}>
<Table />
</AltContainer>
);
}
});

View File

@ -9,7 +9,7 @@ let Route = Router.Route;
let routes = (
<Route name="app" path="/" handler={AscribeApp}>
<Route name="pieces" handler={<PieceList />}>
<Route name="pieces" handler={PieceList}>
<Route name="piece" path="/pieces/:bitcoin_ID_noPrefix" handler={Piece} />
</Route>
</Route>