Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
25
rated 0 times [  30] [ 5]  / answers: 1 / hits: 17529  / 9 Years ago, mon, april 6, 2015, 12:00:00

I'm trying render an element which has an accent character using ReactJS and JSX, but it's not returning what I wanted.



My JSX:



var Orcamento = React.createClass({
render: function() {
return (
<div>
<h1>Orçamento</h1>

</div>
);
}
});

React.render(
<Orcamento/>,
document.getElementById(orcamento)
);


My rendered javascript:



var Orcamento = React.createClass({displayName: Orcamento,
render: function() {
return (
React.createElement(div, null,
React.createElement(h1, null, Orçamento)

)
);
}
});

React.render(
React.createElement(Orcamento, null),
document.getElementById(orcamento)
);


And my result in browser:



Orçamento


I've set <meta charset=UTF-8> in my index file inside the head tag, accent characters works in page title and body if this word is typed direct in page content, but is not working when it's rendered by ReactJs



How can I fix this problem?


More From » reactjs

 Answers
32

What you see, Orçamento, is the result of a UTF-8 byte array being rendered in ASCII, probably codepage ISO 8859-1.


ReactJS doesn't support non-ASCII characters within HTML.


Try this:


var Orcamento = React.createClass({
render: function() {
return (
<div>
<h1> { 'Orçamento' } </h1>

</div>;
);
}
});

Or simply replace Orçamento with Or&#231;amento.


This is well explained in the JSX gotchas.


[#67187] Thursday, April 2, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
blaisep

Total Points: 748
Total Questions: 95
Total Answers: 108

Location: Federated States of Micronesia
Member since Sun, May 16, 2021
3 Years ago
blaisep questions
Wed, Dec 16, 20, 00:00, 4 Years ago
Sun, Aug 16, 20, 00:00, 4 Years ago
Tue, Nov 12, 19, 00:00, 5 Years ago
Mon, Nov 11, 19, 00:00, 5 Years ago
;