way to embed if expressions inside JSX code?

前端 未结 1 1250
时光取名叫无心
时光取名叫无心 2020-12-04 02:12

I guess that stuff that goes into a react tag must be a react tag or a string; a function that returns a tag or string; a collection of tag or string or functions that retur

相关标签:
1条回答
  • 2020-12-04 03:01

    I usually do ternary if statements if there's not much logic or cause for re-use:

    return (
        <div>
            {doSomething ? something : null}
            Something else
        </div>
    );
    
    0 讨论(0)
提交回复
热议问题