Article From:

Official website data: JSX in React uses string literal.

When you pass a string literal, its value is HTML-unescaped. So these two JSX expressions are equivalent:

<MyComponent message="&lt;3" />

<MyComponent message={'<3'} />

What is the meaning of this paragraph? I don’t know what’s the use?

Answer 0:

It means that the value you import is like this.'<3' When HTML has characters, react will help you escape, so they are equivalent.

Answer 1:

reactTo prevent attacks such as XSS, transcoding is done, meaning that the 2 of them are equivalent.

Answer 2:
<MyComponent message={'<3'} />
<MyComponent message='<3' />    // This is the same as the first one, < 3/ / but< MyComponent message= "& lt; 3" /> / / this will escape message from MyComponent.< 3MyComponent message ={"& amp; lt; 3"} / & gt; this will output & amp; lt; 3 as it is, so if you pass'& amp; lt;'This kind of thingStrings can only be written in this way.

Leave a Reply

Your email address will not be published. Required fields are marked *