无法将多行组件添加到变量中

Can't add multiple lines of components into variable

我想根据 if 语句的结果将内容保存在变量中。但是当我添加多行时它不起作用。

let content = null
if(this.props.group.name != null){
  content = <Text>Just this line works</Text>
              <Text>This doesn't work</Text>
}

我不知道该怎么办。我不能像 Javascript.

那样在行尾添加 +

组件需要包装在包含组件的父组件中,除非您将其创建为带有键的数组。

// this would work because it's wrapped inside parentheses and has a parent component
content = (
          <View>
            <Text>Just this line works</Text>
            <Text>This doesn't work</Text>
          </View>
          )

// this works because the components are an array
content = [
           <Text key="1">Just this line works</Text>,
           <Text key="2">This doesn't work</Text>
          ]