-
Notifications
You must be signed in to change notification settings - Fork 46.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Numeric character reference in props not possible due to escaping #3769
Comments
This is already documented, along with the reasoning and several alternatives other than I'd say just use the Unicode version, which is quite simple as you're already using the hexadecimal version for HTML character references (you may have to pad the code with leading zeros as necessary, of course). |
You can do
or if you have it as a string for some reason,
Only the JSX compiler parses HTML entities; React doesn't so you should use the Unicode character instead. |
Thanks @spicyj , you saved my life (well, at least a few hours of my time) here |
Documentation doesn't mention any way how to use html entities anymore, but solution given by @spicyj still works |
I think JSX compilers has gotten smarter and now I can't easily produce meta tags like og:url or og:image in full stack react frameworks like next.js |
The HTML numeric character reference / named character reference does not work for prop-values which is a common use case, e.g. for icons fonts (
data-icon="ሴ"
).It does work for raw strings in this fashion:
But breaks in other scenarios:
Yielding:
The only workaround I found so far is using dangerouslySetInnerHTML, which is a bit unfortunate as it forces me to introduce another wrapper for using a basic HTML feature.
JsFiddle sample
The text was updated successfully, but these errors were encountered: