我正在使用这两个库 import SwipeCards from 'react-native-swipe-cards'; 并从“react-native-auto-typing-text”导入 AutoTypingText;
在我拥有的每张卡片中,我都使用 AutoTypingText,问题是它在所有卡片中都使用相同的文本,唯一改变的是 this.props.Nickname
这不是 AutoTypingText 的 text 属性的一部分
子卡组件:
render() {
return (
<View style={styles.viewStyle}>
<Text style={styles.titleText}>{this.props.Nickname}</Text>
<AutoTypingText
text={"\nAge: " + this.props.Age + "\n"
+ "City: " + this.props.City + "\n"
+ "Recent Login: " + this.props.RecentActivity + "\n"
+ "Points: " + this.props.Points + "\n"
+ "About: \"" + this.props.About + "\"\n"
}
charMovingTime={0}
style={textStyle}
delay={0}
onComplete={() => {
console.log('done');
console.log(this.state)
}}
/>
<View style={{ flexDirection: 'row', justifyContent: 'space-around' }}>
<Button style={styles.buttonStyle} textStyle={styles.buttonText}>
Exploit !
</Button>
<Button style={styles.buttonStyle} textStyle={styles.buttonText}>
Spare
</Button>
</View>
</View>
);
}
}
家长卡清单
const Cards = [
{
Nickname: "S4nr0",
Age: 25,
City: "New-York",
RecentActivity: "17/07/2016 14:11PM",
About: "I <3 Kittenz",
Points: 1337
},
{
Nickname: "Sr00lik",
Age: 23,
City: "New-York",
RecentActivity: "17/07/2016 14:11PM",
About: "If Internet explorer is brave\nenough to ask you to be your\n default browser, you're brave \nenough to ask that girl out",
Points: 1337
},
{
Nickname: "Bomba",
Age: 24,
City: "New-York",
RecentActivity: "17/07/2016 14:11PM",
About: "I'm Awesome !",
Points: 1337
}
];
export default React.createClass({
getInitialState() {
return {
cards: Cards
}
},
render() {
return (
<SwipeCards
cards={this.state.cards}
renderCard={(cardData) => <Card {...cardData} />}
/>
)
}
})
澄清一下:好像 AutoTypingText 就像一个单例(我知道不是),因为它的结果在所有卡片中都是相同的