I want to create a comment component like this:
The problem is I don’t find a way to make the styling for the lorem ipusm text. I tried the next:
<View {...props} style={[styles.main, props.style]}>
<View style={{ display: "flex", flexDirection: "row" }}>
<Avatar user={user} />
<Text style={styles.username}>{user.username}</Text>
</View>
<Text style={styles.comment}>
{comment}
</Text>
</View>
Where comment
would be the lorem Ipsum text. And for the styles:
export const useCommentTheme = () =>
useCreateStyle((colors) => ({
main: {
display: "flex",
flexDirection: "row",
alignItems: "center",
flexWrap: "wrap",
},
username: {
color: colors.primary,
fontFamily: poppins.extraBold,
marginLeft: 5,
fontSize: 16,
},
comment: {
color: colors.text,
marginLeft: 10,
fontSize: 14,
},
}));
What this does is putting all the text under the Avatar and username, not at the side of the username, and add breaks when text overflows. How can I do to make the text breaks
2
Answers
You can use
{'n'}
e.g.It’s simple, just add
numberOfLines
: