mirror of
https://github.com/wassname/talk.git
synced 2026-08-15 12:55:10 +08:00
Use factory
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
import withSortOption from '../hocs/withSortOption';
|
||||
import SortOption from '../components/SortOption';
|
||||
|
||||
export const createSortOption = (label, sort) => withSortOption({...sort, label})(SortOption);
|
||||
@@ -18,14 +18,14 @@ const mapDispatchToProps = (dispatch) =>
|
||||
dispatch
|
||||
);
|
||||
|
||||
export default ({by = 'created_at', order = 'DESC', label}) => hoistStatics((WrappedComponent) => {
|
||||
export default ({sortBy = 'created_at', sortOrder = 'DESC', label}) => hoistStatics((WrappedComponent) => {
|
||||
class WithSortOption extends React.Component {
|
||||
setSort = () => {
|
||||
this.props.setSort({by, order});
|
||||
this.props.setSort({sortBy, sortOrder});
|
||||
}
|
||||
|
||||
render() {
|
||||
const active = this.props.sortOrder === order && this.props.sortBy === by;
|
||||
const active = this.props.sortOrder === sortOrder && this.props.sortBy === sortBy;
|
||||
const resolvedLabel = typeof label === 'function' ? label() : label;
|
||||
return (
|
||||
<WrappedComponent
|
||||
|
||||
Reference in New Issue
Block a user