Add space before text in react js component

I have this component <TEXT>{' '} (CAR)</TEXT>. I try to add an empty space before (CAR) using {' '}, but when the text is rendered the space is gone.
Why the space is not added and how to add it?


Solution 1:

That's just the way HTML renders whitespace as part of the spec.

From MDN: How whitespace is handled by HTML, CSS, and in the DOM:

In the case of HTML, whitespace is largely ignored — whitespace in between words is treated as a single character, and whitespace at the start and end of elements and outside elements is ignored.

If you need visual negative space, you can use a style with padding or margin.

Solution 2:

You can use &nbsp; to create space

<TEXT>&nbsp;&nbsp;(CAR)</TEXT>