michael-s-molina commented on a change in pull request #13409:
URL: https://github.com/apache/superset/pull/13409#discussion_r587351527
##########
File path: superset-frontend/src/components/RefreshLabel/index.tsx
##########
@@ -16,32 +16,38 @@
* specific language governing permissions and limitations
* under the License.
*/
-import React from 'react';
-import PropTypes from 'prop-types';
+import React, { MouseEventHandler } from 'react';
+import { useTheme } from '@superset-ui/core';
import { Tooltip } from 'src/common/components/Tooltip';
+import Icon, { IconProps } from 'src/components/Icon';
-import './RefreshLabel.less';
+export interface RefreshLabelProps {
+ onClick: MouseEventHandler<SVGSVGElement>;
+ tooltipContent: string;
+}
-const propTypes = {
- onClick: PropTypes.func,
- tooltipContent: PropTypes.string.isRequired,
-};
+const RefreshLabel = ({ onClick, tooltipContent }: RefreshLabelProps) => {
+ const theme = useTheme();
-class RefreshLabel extends React.PureComponent {
- render() {
- return (
- <Tooltip title={this.props.tooltipContent} id="cache-desc-tooltip">
- <i
- aria-label="Icon"
- role="button"
- tabIndex={0}
- className="RefreshLabel fa fa-refresh pointer"
- onClick={this.props.onClick}
- />
- </Tooltip>
- );
- }
-}
-RefreshLabel.propTypes = propTypes;
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
+ const IconWithoutRef = React.forwardRef((props: IconProps, ref: any) => (
+ <Icon {...props} />
+ ));
+
+ return (
+ <Tooltip title={tooltipContent}>
+ <IconWithoutRef
+ role="button"
+ onClick={onClick}
+ name="refresh"
+ css={{
Review comment:
We don't need to import [`css`](https://emotion.sh/docs/css-prop) when
using object styles, only when we use string styles. Babel will automatically
convert this property to a `className`.
I'll disagree with you about string style vs object style. What really makes
the difference for me when I chose object style is typescript checking and
autocompletion. You can't do that when using string styles and that is more
error-prone. Also, for me at least, is more natural coming from React and React
Native style pattern.
----------------------------------------------------------------
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]