Ad
If Else For More Than One Date Result
How do you use an if else
to see if there is more than one dates
result?
<If condition={adv_event.dates > 0 }>
<Then>
<p>More than one</p>
</Then>
<Else>
{adv_event.dates.length > 0 ? (
<div className="col-md-4">
{adv_event.dates &&
<DateField props={adv_event.dates} />
}
</div>
) : ''}
</Else>
</If>
Ad
Answer
it's simple use ternary operator.
class TodoApp extends React.Component {
state = {
adv_event :{
data: 10
}
}
render() {
const {adv_event:{data}} = this.state;
return (
<div>
{data >0? <div><p>More than one</p></div> : <div><p>no data</p></div>}
</div>
)
}
}
here is a quick demo
Ad
source: stackoverflow.com
Related Questions
- → Import statement and Babel
- → should I choose reactjs+f7 or f7+vue.js?
- → Uncaught TypeError: Cannot read property '__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED' of undefined
- → .tsx webpack compile fails: Unexpected token <
- → React-router: Passing props to children
- → ListView.DataSource looping data for React Native
- → React Native with visual studio 2015 IDE
- → Can't test submit handler in React component
- → React + Flux - How to avoid global variable
- → Webpack, React & Babel, not rendering DOM
- → How do I determine if a new ReactJS session and/or Browser session has started?
- → Alt @decorators in React-Native
- → How to dynamically add class to parent div of focused input field?
Ad