Reputation: 1372
I'm fetching some data in app from WordPress site successfully. Some entities like "„" react native don't want to make like quotes and many more issues I have.
Is there some way to make HTML entities right in React Native App?
Thanks in advance.
Upvotes: 17
Views: 15488
Reputation: 131
I had the same problem. This is the way I solved it:
First of all install html-entities :
npm install html-entities
In your code :
import {decode} from 'html-entities';
console.log(decode(stringToBeDecoded));
Upvotes: 10
Reputation: 12063
Here's how to import and use a specific subpackage of Entities if the example in 'html-entities' README, which uses require(), won't work for you.
import {Html5Entities} from 'html-entities';
const entities = new Html5Entities();
entities.decode(stringToBeDecoded);
Upvotes: 4
Reputation: 80041
You should be able to use something like html-entities to decode the text before rendering:
const entities = new Entities();
entities.decode('„') // "„" (double low quotation mark)
Upvotes: 19