Skip to content

jsx-wrap-multilines and conditional rendering #1282

Closed
@psixdev

Description

@psixdev

Hi! What do you think about using conditional rendering in this form?

<div>
  <h1>Hello!</h1>
  {unreadMessages.length > 0 &&
    <h2>
      You have {unreadMessages.length} unread messages.
    </h2>
  }
</div>

(example from https://facebook.github.io/react/docs/conditional-rendering.html#inline-if-with-logical--operator)

Perhaps the rule should dictate a next style?

<div>
  <h1>Hello!</h1>
  {unreadMessages.length > 0 && (
    <h2>
      You have {unreadMessages.length} unread messages.
    </h2>
  )}
</div>

Now the first option will not lead to a warning. Even if it's right, what do you think about the first and second examples?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions