0

I've tried the following with no luck, wanted to produce a <!-- Baz --> comment node:

export default {
  render() {
    return (
      <strong>
        Foo
        {/* Baz */}
      </strong>
    )
  },
}
Wenfang Du
  • 8,804
  • 9
  • 59
  • 90

2 Answers2

0

Although it's not strictly JSX, I haven't better way to achieve this:

import { Comment, h } from 'vue'

export default {
  render() {
    return (
      <strong>
        Foo
        {h(Comment, 'Baz')}
      </strong>
    )
  },
}
Wenfang Du
  • 8,804
  • 9
  • 59
  • 90
-1

This works &lt;-- Baz --&gt;

answer 2:

Babel transform will remove jsx comments,you can update your babel version, view this answer or you can use some hack

matt.miao
  • 24
  • 4
  • 1
    That's not a comment node tho. – Wenfang Du Apr 21 '21 at 06:04
  • Babel transform will remove jsx comments,you can update your babel version, view this [answer](https://stackoverflow.com/questions/56666638/how-can-i-keep-comments-when-minifying-my-react-code) or you can use some [hack](https://stackoverflow.com/questions/40015336/how-to-render-a-html-comment-in-react) – matt.miao Apr 21 '21 at 06:28