0
function MyInfo()
    {
    return (
       <div> 
           <p>hi</p>
           <p> this works</p>
       </div>
    )    
}
function MyInfo()
    {
    return 
        (
        <div> 
            <p>hi</p>
            <p> this does not work, and that makes me a sad formatting panda</p>
        </div>
    )    
}

My philosophy is to have each 'block' be indicated by the containing parenthesis on a line dedicated for declaration. everything from object creation to functions and if statements.

However, just learning react and there is an enforcement of having the opening "(" on the same line as return... which forces me to break out of a very consistent pattern.

Is there a work around - a library - a trick... anything that will allow me to format my code consistently (white space is good, white space is great, white space is wonderful).

I think it is easier to parse - easier to debug (I never have to look for things at the end of a line, and it enforces and visually guides indentations), and that's my opinion.

So: is there a way to do this in react, or am I stuck with this 'really spiky to the brain' enforced formatting?

And if there isn't currently a way to do that... why not? Why ENFORCE the ( on the same line as return?

altruios
  • 713
  • 2
  • 16
  • If you add a linebreak after return, a semicolon is automatically inserted like this: `return;`. So, it returns undefined, not the block within `()`. Check the duplicates for more info about Automatic Semicolon Insertion (ASI). – adiga May 20 '20 at 16:03

0 Answers0