reactjs - 将箭头函数返回给组件
问题描述
我有下面的箭头功能,我希望能够将这里的所有内容返回给组件。我如何退回所有东西?是否可以使用导出功能?下面的代码位于一个 js 文件中。
const myTester = props => {
[
{
title: props.intl.formatMessage({
id: "ren_past_due"
}),
icon: (
<EventBusy
color="#cc2444"
style={style}
className="icon-box-icon-image material-icons"
/>
),
color: "#C60C30",
expiresBefore: today()
},
{
title: props.intl.formatMessage({
id: "ren_zerotothree_months"
}),
icon: (
<Today
color="#f2b826"
style={style}
className="icon-box-icon-image material-icons"
/>
),
color: "#F0AB00",
expiresAfter: today(),
expiresBefore: today().add(3, "months")
}
].map(item => {
if (item.expiresBefore) {
item.expiresBefore = item.expiresBefore.format("Y-MM-DD");
}
if (item.expiresAfter) {
item.expiresAfter = item.expiresAfter.format("Y-MM-DD");
}
return item;
});
};
解决方案
在第 2 行return
的前面添加一个。[
返回数组的简写() => ([1, 2, 3]);
。
返回 object的简写() => ({ name: 'shorthand' });
。
推荐阅读
- colors - mayavi 颜色数量和自定义色阶
- pyspark - 基于Filter RDD-PySpark的映射输出
- android - 如何将字节数组转换为位图?
- python - 长字典排序列表
- angular - 角度输入设置器仅触发一次
- java - Slack 请求验证:无法使用签名密钥计算匹配的请求摘要
- kubernetes - 无法加入集群:在 kubeadm 加入期间连接被拒绝
- javascript - 单击标题“价格”后,如何对表格行进行升序和降序排序?
- math - 用陀螺仪测量绕一个轴的旋转
- javascript - 如何从与angularjs中第一个数组大小相同的两个数组中获取一个数组?