我是React js的新手。我在下面的代碼中給出了語法錯誤。任何人都可以幫我解決這個問題。React js if else condition
import React, { PropTypes } from 'react';
import uncontrollable from 'uncontrollable';
import CSSModules from 'react-css-modules';
import cn from 'classnames';
import styles from './Tab.scss';
export const Tab = ({title, isActive, children}) => (
if(isActive){
<div styleName='tab active' >{title}</div>
}else{
<div styleName='tab ' >{title}</div>
}
);
Tab.propTypes = {
isActive: PropTypes.bool,
children: PropTypes.any,
title: PropTypes.any,
};
export default uncontrollable(CSSModules(Tab, styles, {allowMultiple: true}), {
});
以下是錯誤。
ERROR在./src/components/Tab/Tab.jsx 模塊構建失敗:語法錯誤:意外的令牌(10:4)
8 |
9 | export const Tab = ({title, isActive, children}) => (
> 10 | if(isActive){
| ^
11 | <div styleName='tab active' >{title}</div>
12 | }else{
13 | <div styleName='tab ' >{title}</div>
@ ./src/components/Tab/index.js 7:11-27