- 此问题在此处已有答案**:
Is it possible to use if...else... statement in React render function?(24个答案)
6小时前关闭.
const ContactsTableRow = ({ item, columns }: ContactsTableRowProps) => {
return (
<tr className={styles.body__tr}>
{columns.map((columnItem: { name: string }, index: number) => {
return (
<Link to={'/contacts/99'}
className={clsx(styles.action__title, styles.action__link)}>
{if (columnItem.name === "id") {
return (
<td
key={index}
className={clsx([styles.body__td, styles.body__action])}
>
<p className={clsx(styles.action__title, styles.action__link)}>
{item[`${columnItem.name}`]}
</p>
</td>
);
}
}
</Link>
)
我想用点击转到另一个页面,我用 Package 了这个,但是出现错误:}预期TS1109:需要表达式。!
1条答案
按热度按时间ffvjumwh1#
Conditional Rendering in React