Wednesday, February 19, 2020

ReactNative: understanding alignment of Views and Texts.

why does the Text take up the full space of the View, instead of just the space for "Hello"?
Because of the View is a flex container and by default has flexDirection: 'column' and alignItems: 'stretch', which means that its children should be stretched out to fill its width.
(Note, per the docs, that all components in React Native are display: 'flex' by default and that display: 'inline' does not exist at all. In this way, the default behaviour of a Text within a View in React Native differs from the default behaviour of span within a div on the web; in the latter case, the span would not fill the width of the div because of a span is an inline element by default. There is no such concept in React Native.)
How can the Text be floated / aligned to the right?
The float the property doesn't exist in React Native, but there are loads of options available to you (with slightly different behaviours) that will let you right-align your text. Here are the ones I can think of:

1. Use textAlign: 'right' on the Text element

<View>
  <Text style={{textAlign: 'right'}}>Hello, World!</Text>
</View>
(This approach doesn't change the fact that the Text fills the entire width of the View; it just right-aligns the text within the Text.)

2. Use alignSelf: 'flex-end' on the Text

<View>
  <Text style={{alignSelf: 'flex-end'}}>Hello, World!</Text>
</View>
This shrinks the Text element to the size required to hold its content and puts it at the end of the cross direction (the horizontal direction, by default) of the View.

3. Use alignItems: 'flex-end' on the View

<View style={{alignItems: 'flex-end'}}>
  <Text>Hello, World!</Text>
</View>
This is equivalent to setting alignSelf: 'flex-end' on all the View's children.

4. Use flexDirection: 'row' and justifyContent: 'flex-end' on the View

<View style={{flexDirection: 'row', justifyContent: 'flex-end'}}>
  <Text>Hello, World!</Text>
</View>
flexDirection: 'row' sets the main direction of the layout to be horizontal instead of vertical; justifyContent is just like alignItems, but controls alignment in the main direction instead of the cross direction.

5. Use flexDirection: 'row' on the View and marginLeft: 'auto' on the Text

<View style={{flexDirection: 'row'}}>
  <Text style={{marginLeft: 'auto'}}>Hello, World!</Text>
</View>
This approach is demonstrated, in the context of the web and real CSS, at https://stackoverflow.com/a/34063808/1709587.

6. Use position: 'absolute' and right: 0 on the Text:

<View>
  <Text style={{position: 'absolute', right: 0}}>Hello, World!</Text>
</View>
Like in real CSS, this takes the Text "out of flow", meaning that its siblings will be able to overlap it and its vertical position will be at the top of the View by default (although you can explicitly set a distance from the top of the View using the top style property).

Naturally, which of these various approaches you want to use - and whether the choice between them even matters at all - will depend upon your precise circumstances.

Understanding Tag Wiki Suggestion edits. How to do it, and suggestion for the forum if it helps.

I don't know whether the following post is eligible for down-voting, but please infer any viable suggestions as far as possible.
Seeing to posts:
I feel that there are tags that are like 'email', that is they are self-explanatory and don't need any tag edit suggestions.
There were tags that I thought needed suggestions, but that was my opinion. These are self-explanatory and don't need tag edits. This is a difficult job.
To minimize such penalties, there should be privileges.
I. Special privileges should be for the moderators to mark new tags or those tags that fall in such categories, like the ones that are not editable, so that others do not have to pay a penalty, sooner or later.
II. If the moderator team is unable to reply to a question raised in the contacts, the same post should not be penalized in the forum. Instead, these posts should be just deleted with the message that there was a rude behavior, or the posts do not belong in the forum or whatever other reason.
III. Instead of contacts, there should be a proper forum, where there is no down-voting. The messages should be private, and the questions should be only visible to the moderators and the person who posted it.

Some mistakes that I did, unknowingly and others may be doing.
  1. https://stackoverflow.com/edit-tag-wiki/141989
The network solutions are a company, that is, as they say, is the World's first domain registrar with over 25 years of experience.
--
This is with reference to a network solutions company, which is the World's first domain registrar with over 25 years of experience.
Derived from the quotation from the web-site, about the company:
They are a team full of technical expertise to help the clients with anything they need related to the products and services they provide. They are trained to troubleshoot and assist clients to resolve any of their technical issues.

  1. https://stackoverflow.com/edit-tag-wiki/141990
NGINX provides an open-source HTTP server and HTTP upstream is one of its modules.
-- The ngx_http_upstream_module module is used to define groups of servers that can be referenced by the proxy_passfastcgi_passuwsgi_passscgi_passmemcached_pass, and grpc_pass directives.

  1. https://stackoverflow.com/edit-tag-wiki/141988
Inside GitHub Actions the runner is the application, that runs a job from its workflow. The runner, as said on the website, can run on the hosted machine pools or run on self-hosted environments.
-- A GitHub-hosted runner is a virtual machine hosted by GitHub with the GitHub Actions runner application installed. GitHub offers runners with Linux, Windows, and macOS operating systems. When you use a GitHub-hosted runner, machine maintenance and upgrades are taken care of for you.

Please see the list of edits I have done in the last two days:
(Note: Elaboration of some of the failed edits, in the link above, are already discussed in one of the answers to this question, where the same pattern of failure is repeated again and again.)
Thus I have found out more answers.
So it seems there is a lot for me to learn before proceeding to further edits after a lot of failures.
I have also seen this post during my edit ban: For how long I am banned for edits?
This post proves that the rejection is also about preventing bad behavior and bad practices until you are aware of it. Burnination leads to mass editing, and if not done with proper research, it has a drastic effect. So one has to prepare for a permanent ban if the failures are becoming unacceptably numerous.

Things that I have inferred till now :
Seeking Resolutions For The Common Problems While Editing The Posts
I have tried to improve the look of the questions or answers, emphasizing on the keywords, such that it grabs attention (even if the tags are already there), to see whether a post conveys the intentions/efforts clearly, and then it is properly understood.
In the process, by looking at the rejected edits, I have learned:
  1. The real use of quotations (just quote from the external sources or evidence),
  2. Links with labels (not always necessary, but it looks clean and describes the context of the place it will take you to),
  3. Code wrapper (for pieces of code or programming language keywords only),
  4. Bold and italicized words to emphasize a sentence that describes a problem or words that relate to the jargon of the language (if used incorrectly, it may impact the readability of the question).
  5. For numbered lists and bulleted lists, this is the best example, because, in earlier stages of this post, the readability was bizarre. So you can explain your problem point by point.
  6. You can divide your post into sections using a horizontal rule.
  7. You can try two different sizes of the text: header and normal.
The most common review comment is:
This edit does not make the post even a little bit easier to read, easier to find, more accurate or more accessible. Changes are either completely superfluous or actively harm readability.
I need to understand, in what ways, grammatical corrections, and other suggestions, ended up in the reviews like that of the above, and others?
(Note: I have realized that it is not necessary to edit a sentence if the grammar is still correct enough to convey its intent properly. Only unnecessary portions of the post should be removed.)

WHAT TO LOOK FOR WHILE EDITING A POST AND TO MAKE AWARE TO THE POST OWNER HOW TO ASK A QUESTION
Putting my inferences till now:
  • No need to edit the post if, in spite of grammar, it conveys what it wants to.
  • If the post is still not conveying what it wants to, even when the structure is good, and the details are not put in, you can down-vote, a flag to close with a comment that more efforts are needed by the question owner him/herself to improve the post.
  • Often there are sentences that are not useful to the post. These may be removed.
  • There may be issues of improper formatting.
  • If there are unrelated questions within the same post, then you can edit out to remove the question and suggest the post owner, that the post can be asked as a separate question in SOW.
  • The post owner should be careful in arguments with the contributors and moderators. He/she should not become adamant that he/she is doing good, even when reputed peers are advising that something he/she is doing is wrong.
  • You can flag or remove dead source links in the post.
For StackOverflow:
Is your question about programming?
We prefer questions that can be answered, not just discussed.
Provide details. Share your research.
If your question is about this website, ask it on meta (here) instead.
Hence the rejection of the above question in the link was correct.
With the help of the solutions I get, I can improve past and future suggestions edits.