I am trying to truncate text in my react application. I decided to use the "ellipsizeMode" attribute, but I cannot get it to work.
I wrote a demo of the problem:
'use strict'; import React, { Component } from 'react'; import { StyleSheet, Text, View, } from 'react-native'; export class EllipsizeModeTest extends Component { render() { return ( <View style={styles.container}> <Text style={styles.text}>{'first part | '}</Text> <Text style={styles.text} numberOfLines={1} ellipsizeMode={'tail'}> {'a text too long to be displayed on the screen'} </Text> </View> ); } } const styles = StyleSheet.create({ container: { flexDirection: 'row', }, text: { fontSize: 20, } });
Now the text is not truncated, any idea why?
javascript design reactjs react-native
aguilbau
source share