lilykuang commented on a change in pull request #10290:
URL:
https://github.com/apache/incubator-superset/pull/10290#discussion_r453127256
##########
File path: superset-frontend/src/components/Menu/SubMenu.tsx
##########
@@ -64,71 +64,72 @@ const StyledHeader = styled.header`
`;
interface SubMenuProps {
- createButton?: { name: string; url: string | null };
canCreate?: boolean;
- name: string;
childs?: Array<{ label: string; name: string; url: string }>;
+ createButton?: { name: string; url: string | null };
+ fetchData?: () => void;
+ name: string;
}
-interface SubMenuState {
- selectedMenu: string;
- isModalOpen: boolean;
-}
-
-class SubMenu extends React.PureComponent<SubMenuProps, SubMenuState> {
- state: SubMenuState = {
- selectedMenu:
- this.props.childs && this.props.childs[0]
- ? this.props.childs[0].label
- : '',
- isModalOpen: false,
- };
+const SubMenu = ({
+ canCreate,
+ childs,
+ createButton,
+ fetchData,
+ name,
+}: SubMenuProps) => {
+ const [isModalOpen, setIsModalOpen] = useState(false);
+ const [selectedMenu, setSelectedMenu] = useState(
+ (childs && childs[0] && childs[0].label) || '',
Review comment:
good suggestion! it doesn't need to default to empty string
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]