diff --git a/webapp/src/components/boardColumn.tsx b/webapp/src/components/boardColumn.tsx index 601d4883a..ee089719a 100644 --- a/webapp/src/components/boardColumn.tsx +++ b/webapp/src/components/boardColumn.tsx @@ -1,57 +1,49 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import React from 'react' +import React, {useState} from 'react' type Props = { onDrop: (e: React.DragEvent) => void isDropZone: boolean + children: React.ReactNode } -type State = { - isDragOver: boolean -} +const BoardColumn = React.memo((props: Props) => { + const [isDragOver, setIsDragOver] = useState(false) -class BoardColumn extends React.PureComponent { - state = { - isDragOver: false, + let className = 'octo-board-column' + if (props.isDropZone && isDragOver) { + className += ' dragover' } + return ( +
{ + e.preventDefault() + if (!isDragOver) { + setIsDragOver(true) + } + }} + onDragEnter={(e) => { + e.preventDefault() + if (!isDragOver) { + setIsDragOver(true) + } + }} + onDragLeave={(e) => { + e.preventDefault() + setIsDragOver(false) + }} + onDrop={(e) => { + setIsDragOver(false) + if (props.isDropZone) { + props.onDrop(e) + } + }} + > + {props.children} +
+ ) +}) - render(): JSX.Element { - let className = 'octo-board-column' - if (this.props.isDropZone && this.state.isDragOver) { - className += ' dragover' - } - const element = ( -
{ - e.preventDefault() - if (!this.state.isDragOver) { - this.setState({isDragOver: true}) - } - }} - onDragEnter={(e) => { - e.preventDefault() - if (!this.state.isDragOver) { - this.setState({isDragOver: true}) - } - }} - onDragLeave={(e) => { - e.preventDefault() - this.setState({isDragOver: false}) - }} - onDrop={(e) => { - this.setState({isDragOver: false}) - if (this.props.isDropZone) { - this.props.onDrop(e) - } - }} - > - {this.props.children} -
) - - return element - } -} - -export {BoardColumn} +export default BoardColumn diff --git a/webapp/src/components/boardComponent.tsx b/webapp/src/components/boardComponent.tsx index 5f36fd384..376fb67b3 100644 --- a/webapp/src/components/boardComponent.tsx +++ b/webapp/src/components/boardComponent.tsx @@ -23,7 +23,7 @@ import Menu from '../widgets/menu' import MenuWrapper from '../widgets/menuWrapper' import BoardCard from './boardCard' -import {BoardColumn} from './boardColumn' +import BoardColumn from './boardColumn' import './boardComponent.scss' import CardDialog from './cardDialog' import {Editable} from './editable'