|
1 | | -import { Component, ReactNode, createElement } from "react"; |
| 1 | +import { ReactNode, createElement } from "react"; |
2 | 2 | import { DropDown, getFilteredProps, DropDownProps } from "./components/DropDown"; |
3 | 3 | import { hot } from "react-hot-loader/root"; |
4 | 4 | import { DropdownContainerContainerProps } from "../typings/DropdownContainerProps"; |
5 | 5 |
|
6 | 6 | import "./ui/DropdownContainer.scss"; |
7 | 7 |
|
8 | | -class DropdownContainer extends Component<DropdownContainerContainerProps> { |
9 | | - constructor(props: DropdownContainerContainerProps) { |
10 | | - super(props); |
| 8 | +const DropdownContainer = (props: DropdownContainerContainerProps): ReactNode => { |
| 9 | + const filteredProps: DropDownProps = getFilteredProps(props); |
| 10 | + const { generalButtonText, style, splitButtonSplitButtonClicked } = props; |
11 | 11 |
|
12 | | - this.handleClick = this.handleClick.bind(this); |
13 | | - } |
14 | | - |
15 | | - render(): ReactNode { |
16 | | - const filteredProps: DropDownProps = getFilteredProps(this.props); |
17 | | - const { generalButtonText, style } = this.props; |
18 | | - |
19 | | - if (!generalButtonText) { |
20 | | - return null; |
| 12 | + const handleClick = (): void => { |
| 13 | + if (splitButtonSplitButtonClicked && splitButtonSplitButtonClicked.canExecute) { |
| 14 | + splitButtonSplitButtonClicked.execute(); |
21 | 15 | } |
22 | | - const buttonText = generalButtonText.status === "available" ? generalButtonText.value : ""; |
| 16 | + }; |
23 | 17 |
|
24 | | - return ( |
25 | | - <DropDown {...filteredProps} buttonText={buttonText} splitButtonAction={this.handleClick} style={style} /> |
26 | | - ); |
| 18 | + if (!generalButtonText) { |
| 19 | + return null; |
27 | 20 | } |
| 21 | + const buttonText = generalButtonText.status === "available" ? generalButtonText.value : ""; |
28 | 22 |
|
29 | | - private handleClick(): void { |
30 | | - if (this.props.splitButtonSplitButtonClicked && this.props.splitButtonSplitButtonClicked.canExecute) { |
31 | | - this.props.splitButtonSplitButtonClicked.execute(); |
32 | | - } |
33 | | - } |
34 | | -} |
| 23 | + return <DropDown {...filteredProps} buttonText={buttonText} splitButtonAction={handleClick} style={style} />; |
| 24 | +}; |
35 | 25 |
|
36 | 26 | export default hot(DropdownContainer); |
0 commit comments