reactjs - 从 ts 组件传递要在 SASS 中使用的属性
问题描述
我正在尝试将一些属性(高度和宽度)传递给 Icon 组件(只能采用 3 个属性 className path 和 viewBox),因此我不能使用内联样式来添加宽度和高度。有没有办法传递要在 Sass 中使用的高度和宽度属性?这是组件:
import React, { memo } from 'react';
import { Icon } from '@kame/ui';
import classNames from 'classnames';
import styles from './creation-button.module.scss';
type Props = {
icon: {
path: string;
viewBox: string;
height: 20px
width: 20px
};
title: string;
onClick: () => void;
key: string;
};
function CreationButton(props: Props): JSX.Element {
return (
<button onClick={props.onClick} type="button" className={styles['button']}>
<div className={styles['button__icon-container']}>
<Icon
className={styles['button__icon']}
path={props.icon.path}
viewBox={props.icon.viewBox}
/>
</div>
<span className={styles['button__title']}>{props.title}</span>
</button>
);
}
export default memo(CreationButton);
解决方案
推荐阅读
- python - 尝试使用不同的方法安装 tweepy 时出现错误
- css - 将背景位置推离屏幕到左侧
- r - 如何在层次聚类中计算平方和内的总数
- javascript - 未捕获的类型错误:无法读取未定义的属性“substr”(javascript)
- ios - 在遗留项目中支持 SwiftUI 导航
- markdown - 在 swagger UI 中如何展开和向下滚动到单击页面描述中的链接的操作
- javascript - 如何可视化地址的地理编码?并且在理想情况下知道这是否在我的多边形内?
- pandas - 如何更改熊猫列表的方向
- javascript - 有用户聊天输出到 socket.io 中的管理员聊天吗?
- python - fetch --nohooks --no-history chromium 抛出错误:depot_tools/fetch: line 8: exec: python: not found