React native 如何在React Native中将某些文本设置为粗体?

React native 如何在React Native中将某些文本设置为粗体?,react-native,text,render,react-props,React Native,Text,Render,React Props,我知道如何设置一些粗体文本,如下所示 <Text>I am<Text style={{fontWeight:bold}}>a developer</Text></Text> I开发者 但我需要如何使用道具 例如 <FlatList data={[{ title: 'I am<Text style={styles.bold}>a developer</Text>',

我知道如何设置一些粗体文本,如下所示

<Text>I am<Text style={{fontWeight:bold}}>a developer</Text></Text>
I开发者
但我需要如何使用道具

例如

  <FlatList
          data={[{
            title: 'I am<Text style={styles.bold}>a developer</Text>',
            key: 'item1',
            id: 1
          }]}
          extraData={this.state}
          renderItem={this._renderItem}
        />

平面列表中的标题用于_renderItem

<Text>this.props.title</Text>
this.props.title
但它显示在设备的屏幕上,如下所示

<Text>I am<Text style={{fontWeight:bold}}>a developer</Text></Text>
I ama开发者


道具中的标题仅呈现为字符串。

我想您应该将jsx传递给标题道具:

title: {<Text>I am <Text style={{fontWeight:bold}}>a developer</Text></Text>}
标题:{我是开发人员}
编辑:如果这不起作用,你可以用两个道具分开你的标题:

<FlatList
    data={[{
      title: 'I am',
      titleBold: 'a developer'
      key: 'item1',
      id: 1
    }]}
    extraData={this.state}
    renderItem={this._renderItem}
 />

然后在_renderItem中按如下方式显示:

<Text>{this.props.title}<Text style={styles.bold}>{this.props.titleBold}</Text></Text>
{this.props.title}{this.props.titleBold}