Improve commenting of JSX
See original GitHub issueI detected some problems with jsx comments.
Uncomment doesn’t work
If I comment one line and then uncomment it, some curlybraces are being leaved behind.
before
after
should be
Indentation spaces shouldn’t be included on the comment
before
after
should be
Inner component is not commented if indentation spaces are not selected
If you select a component like in the next screenshot the comment shortcut doesn’t work
Use normal javascript comments instead of jsx when the code is inside parenthesis ()
before
after
should be
The javascript that Im using for this examples
function HelloWorld({
greeting = "hello",
greeted = '"World"',
silent = false,
onMouseOver
}) {
if (!greeting) {
return null;
}
// TODO: Don't use random in render
let num = Math.floor(Math.random() * 1e7)
.toString()
.replace(/\.\d+/gi, "");
return (
<div
className="HelloWorld"
title={`You are visitor number ${num}`}
onMouseOver={onMouseOver}
>
<strong>
{greeting.slice(0, 1).toUpperCase() + greeting.slice(1).toLowerCase()}
</strong>
{greeting.endsWith(",") ? (
" "
) : (
<span style={{ color: "grey" }}>", "</span>
)}
<em>{greeted}</em>
{silent ? "." : "!"}
</div>
);
}
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
How to comment in React JSX - Wes Bos
If you use Sublime Text, I've created a little snippet so you can just type jc + TAB to get a quick comment....
Read more >How to use comments in React - Stack Overflow
Within React(JSX), you can use {/* comment here */} , however for javascript // comment here works. So, the answer depends on where...
Read more >Improve formatting of comments in JSX · Issue #4646 - GitHub
In JSX. Your example is something else though: A good old block with a comment inside, followed by a JSX element. That looks...
Read more >React Native Comments - 2 Ways to Add Comments in JSX
If you want to comment a single line then you can use Double Forward Slash(//) but it can only be used outside of...
Read more >How to write comments in ReactJS ? - GeeksforGeeks
Example 1: Comments for React Components. We can write comments in React using the double forward-slash // or the asterisk format /* */ ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Will this be of any use?
https://programmingliftoff.com/enable-jsx-commenting-sublime-text-3/
Looks Like vscode handle jsx comments very good, maybe it can be useful for some inspiration.