mirror of
https://github.com/ascribe/onion.git
synced 2024-12-22 17:33:14 +01:00
refactor to use AltContainer to start developing the new table component
This commit is contained in:
parent
148b019ff9
commit
ba71bd5788
@ -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>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user