Skip to content

Commit

Permalink
Convert class based component to functional component
Browse files Browse the repository at this point in the history
  • Loading branch information
Damans227 committed Nov 3, 2021
1 parent fd1c2fe commit d8dbf0b
Showing 1 changed file with 21 additions and 26 deletions.
47 changes: 21 additions & 26 deletions superset-frontend/src/dashboard/components/dnd/DragHandle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,25 @@ interface DragHandleProps {
dotCount: number;
}

export default class DragHandle extends React.PureComponent<DragHandleProps> {
static defaultProps = {
position: 'left',
innerRef: null,
dotCount: 8,
};

render() {
const { innerRef, position, dotCount } = this.props;
return (
<div
ref={innerRef}
className={cx(
'drag-handle',
position === 'left' && 'drag-handle--left',
position === 'top' && 'drag-handle--top',
)}
>
{Array(dotCount)
.fill(null)
.map((_, i) => (
<div key={`handle-dot-${i}`} className="drag-handle-dot" />
))}
</div>
);
}
export default function DragHandle({
position = 'left',
innerRef = null,
dotCount = 8,
}: DragHandleProps) {
return (
<div
ref={innerRef}
className={cx(
'drag-handle',
position === 'left' && 'drag-handle--left',
position === 'top' && 'drag-handle--top',
)}
>
{Array(dotCount)
.fill(null)
.map((_, i) => (
<div key={`handle-dot-${i}`} className="drag-handle-dot" />
))}
</div>
);
}

0 comments on commit d8dbf0b

Please sign in to comment.