H
H
Hellas2017-01-28 14:53:19
React
Hellas, 2017-01-28 14:53:19

Why does react leave "0" on the page?

When the block is hidden, react leaves zero.

{ this.state.data.reply.length &&
  <div className="reply">
    <Posts messages={this.state.data.reply}/>
  </div>
}

<!-- react-text: 57 -->
"0"
<!-- /react-text -->

How to avoid it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
juicyigor, 2017-01-28
@Hellas

this.state.data.reply.lengthis 0, so 0 is output. Try this:

{!!this.state.data.reply.length &&
  <div className="reply">
    <Posts messages={this.state.data.reply}/>
  </div>
}

{this.state.data.reply.length > 0 &&
  <div className="reply">
    <Posts messages={this.state.data.reply}/>
  </div>
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question