React-Redux : DisplayMessages App

Would it helpful to add an if statement to the submitMessage() method to prevent submitting empty messages to the ul ?

Would you mind providing some context?

Like some code and if this is for a challenge please post a link to the challenge.

Submit message method:

submitMessage() {
// if statement prevents submitting a blank input “”
if(this.state.input !== ‘’) {
this.setState({
input: ‘’, messages: […this.state.messages, this.state.input]
});
}
}

Challenge link:

Sure that would make sense to check for (unless you want the user to be able to add empty list items).

You would probably implement input validation with some feedback to the user. The submit method would likely also be on a form submit which would allow you to use client-side validation as well (e.g. required and minlength attributes).