react-native-web icon indicating copy to clipboard operation
react-native-web copied to clipboard

Rendering looses spaces

Open miketheanimal opened this issue 10 years ago • 2 comments

This might not be a bug, and might be OK with some work-around ...

If I have something like

let text = 'One two' ;
....
<Text>{text}</Text>

then visually it renders correctly and I see the space. However if I have:

let left = 'One ' ;
let right = 'Two ' ;
....
<Text>{left}</Text><Text>{right}</Text>

then visually the space disappears, although it is actually there in the DOM:

<span>One </span><span>Two</span>

This is a problem for me, as I actually want to render the string with a cursor marker in the middle which can be animated to blink, ie., (ignoring the actual animation stuff) something like:

<Text>{left}</Text><Text>|</Text><Text>{right}</Text>

I guess that converting all spaces in strings within ... to   within react-native-web would fix my problem, but then:

<Text>
    Spaces and newlines at each end!
</Text>

would break?

miketheanimal avatar Jul 30 '16 10:07 miketheanimal

This looks like default React behaviour. Not sure what result you're trying to get. Something like this?

<Text>
  <Text>One </Text><Text>|</Text><Text> Two</Text>
</Text>

necolas avatar Jul 30 '16 18:07 necolas

If that's the default behaviour when I'll have to live with it:) The effect I'm trying to get is a blinking cursor in the middle of some text without loosing visibility of spaces immediately before or after the cursor.

miketheanimal avatar Jul 31 '16 17:07 miketheanimal