import React from 'react'; const { sortable } = require('react-sortable'); import { ListItem } from './listItem.jsx' const SortableListItem = sortable(ListItem); // interface SortableListProps { // data: data; // } // // interface data { // items: any // } class SortableList extends React.Component { constructor(props: any) { super(props) this.state = { draggingIndex: null, data: { items: this.props.data } } this.updateState = this.updateState.bind(this) } componentWillReceiveProps(nextProps: any) { if (nextProps.data !== this.state.data.items) { this.setState({data: {items: nextProps.data}}) } } updateState(obj: object) { this.setState(obj, this.props.sortCallback(this.state)); } render() { const childProps = { className: 'myClass1' }; const listItems = this.state.data.items.map((item: any, i: number) => { return ( {item} ); }, this); return (
{listItems}
); } } export { SortableList }