mardi 27 mars 2018

How do I set a condition from props?

In my react component

render() {
let hasTask = this.props.task

return <div>
 {hasTask && <div> I have a task </div>}
</div>
 }

Works perfectly fine, except when the props doesn't have a task. what is the best way to handles this in react.

I am really sorry for the simple question. I have to start from somewhere.

Aucun commentaire:

Enregistrer un commentaire