Spaces:
Running
Running
File size: 1,051 Bytes
6bcb42f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
import React from 'react';
import PropTypes from 'prop-types';
import bindAll from 'lodash.bindall';
class SortableAsset extends React.Component {
constructor (props) {
super(props);
bindAll(this, [
'setRef'
]);
}
componentDidMount () {
this.props.onAddSortable(this.ref);
}
componentWillUnmount () {
this.props.onRemoveSortable(this.ref);
}
setRef (ref) {
this.ref = ref;
}
render () {
return (
<div
className={this.props.className}
ref={this.setRef}
style={{
order: this.props.index
}}
>
{this.props.children}
</div>
);
}
}
SortableAsset.propTypes = {
children: PropTypes.node.isRequired,
className: PropTypes.string,
index: PropTypes.number.isRequired,
onAddSortable: PropTypes.func.isRequired,
onRemoveSortable: PropTypes.func.isRequired
};
export default SortableAsset;
|