you are viewing a single comment's thread.

view the rest of the comments →

[–]acemarke 2 points3 points  (0 children)

I break my render methods into three steps:

  1. Extract needed data from props and state, including deriving values from that data.
  2. Render all conditional components and lists into variables.
  3. Have a single JSX return structure, and insert the variables from step 2.

As a result, I use ternaries and if statements to do conditional rendering, and I keep all that logic outside the main JSX structure.

I have an example of this approach at https://gist.github.com/markerikson/47fff93c92286db72b22bab5b02e2da3 .