[GH-ISSUE #68] Newline in Text #38

Closed
opened 2026-05-05 11:30:43 -06:00 by gitea-mirror · 7 comments
Owner

Originally created by @mischnic on GitHub (Mar 23, 2018).
Original GitHub issue: https://github.com/kusti8/proton-native/issues/68

libui correctly displays literal newline characters (\n) in labels.
This works:

<Text stretchy={false}>{"AutoUpdate sucht nach Updateversionen der Microsoft-Software. Weitere Informationen zu \n AutoUpdate finden sie in der Hilfe."}</Text> 

This doesn't:

<Text stretchy={false}>AutoUpdate sucht nach Updateversionen der Microsoft-Software. Weitere Informationen zu {'\n'} AutoUpdate finden sie in der Hilfe.</Text> 

Results in some extra commas and an error message: text , <line break>, text

$ npx babel-node app.js
Warning: Failed prop type: Invalid prop `children` of type `array` supplied to `Text`, expected `string`.
$

bildschirmfoto 2018-03-23 um 16 34 32

So the children array needs to be properly joined when rendering.

Originally created by @mischnic on GitHub (Mar 23, 2018). Original GitHub issue: https://github.com/kusti8/proton-native/issues/68 libui correctly displays literal newline characters (`\n`) in labels. This works: ```jsx <Text stretchy={false}>{"AutoUpdate sucht nach Updateversionen der Microsoft-Software. Weitere Informationen zu \n AutoUpdate finden sie in der Hilfe."}</Text> ``` This doesn't: ```jsx <Text stretchy={false}>AutoUpdate sucht nach Updateversionen der Microsoft-Software. Weitere Informationen zu {'\n'} AutoUpdate finden sie in der Hilfe.</Text> ``` Results in some extra commas and an error message: `text , <line break>, text` ``` $ npx babel-node app.js Warning: Failed prop type: Invalid prop `children` of type `array` supplied to `Text`, expected `string`. $ ``` ![bildschirmfoto 2018-03-23 um 16 34 32](https://user-images.githubusercontent.com/4586894/37838443-29389376-2eb8-11e8-8905-ccc85b834401.png) So the children array needs to be properly joined when rendering.
Author
Owner

@baoanhng commented on GitHub (Mar 27, 2018):

@mischnic You have to do it React way like this

<Text>{`
Line 1
Line 2
`}</Text>
<!-- gh-comment-id:376539034 --> @baoanhng commented on GitHub (Mar 27, 2018): @mischnic You have to do it React way like this ``` <Text>{` Line 1 Line 2 `}</Text> ```
Author
Owner

@mischnic commented on GitHub (Mar 27, 2018):

Yes, that works (see the first code snippet above).

First result for "react native newline":

<Text>
Hi~{"\n"}
this is a test message.
</Text>

In normal React, it would be <br/>.

<!-- gh-comment-id:376638005 --> @mischnic commented on GitHub (Mar 27, 2018): Yes, that works (see the first code snippet above). First result for "react native newline": ```jsx <Text> Hi~{"\n"} this is a test message. </Text> ``` In normal React, it would be `<br/>`.
Author
Owner

@kusti8 commented on GitHub (Mar 30, 2018):

I don't think I'm going to fix this. It's better in my opinion to do it as a simple multiline string, rather than that way.

<!-- gh-comment-id:377536096 --> @kusti8 commented on GitHub (Mar 30, 2018): I don't think I'm going to fix this. It's better in my opinion to do it as a simple multiline string, rather than that way.
Author
Owner

@parro-it commented on GitHub (Mar 30, 2018):

I don't think I'm going to fix this. It's better in my opinion to do it as a simple multiline string, rather than that way.

How do you plan to manage non-hard lines break and indentation?

<!-- gh-comment-id:377539710 --> @parro-it commented on GitHub (Mar 30, 2018): > I don't think I'm going to fix this. It's better in my opinion to do it as a simple multiline string, rather than that way. How do you plan to manage non-hard lines break and indentation?
Author
Owner

@kusti8 commented on GitHub (Mar 30, 2018):

In libui-node there isn't a way to wrap text right? And as for indenting the \t works fine.

<Text>{"123\t456"}</Text>
<!-- gh-comment-id:377545775 --> @kusti8 commented on GitHub (Mar 30, 2018): In libui-node there isn't a way to wrap text right? And as for indenting the \t works fine. ```jsx <Text>{"123\t456"}</Text> ```
Author
Owner

@parro-it commented on GitHub (Mar 30, 2018):

In libui-node there isn't a way to wrap text right?

Not at the moment, but there is an uiNewMultilineEntryfunction that should return a wrappable multine text entry (I'm currently using uiNewNonWrappingMultilineEntry).

I'll add binding for that.

<!-- gh-comment-id:377547380 --> @parro-it commented on GitHub (Mar 30, 2018): > In libui-node there isn't a way to wrap text right? Not at the moment, but there is an `uiNewMultilineEntry`function that should return a wrappable multine text entry (I'm currently using `uiNewNonWrappingMultilineEntry`). I'll add binding for that.
Author
Owner

@parro-it commented on GitHub (Apr 11, 2018):

see https://github.com/parro-it/libui-node/issues/85

<!-- gh-comment-id:380467636 --> @parro-it commented on GitHub (Apr 11, 2018): see https://github.com/parro-it/libui-node/issues/85
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/proton-native#38
No description provided.