While I was searching for a solution on Google, I found this react-native-rss-parser (https://www.npmjs.com/package/react-native-rss-parser).
It has this usage example:
import * as rssParser from 'react-native-rss-parser';
return fetch('http://www.nasa.gov/rss/dyn/breaking_news.rss')
.then((response) => response.text())
.then((responseData) => rssParser.parse(responseData))
.then((rss) => {
console.log(rss.title);
console.log(rss.items.length);
});
But when I try
useEffect(() => {
fetch('http://www.nasa.gov/rss/dyn/breaking_news.rss')
.then((response) => response.text())
.then((responseData) => rssParser.parse(responseData))
.then((rss) => {
console.log(rss.title);
console.log(rss.items.length);
})
.catch((err) => console.log(err));
}, []);
It gives me this error:
[TypeError: _this.getElementTextContentArray is not a function. (In '_this.getElementTextContentArray(node, tagName, namespace)', '_this.getElementTextContentArray' is undefined)]
What can I do? Does anyone know any other solution?
Seems to be an issue related to the newest version 1.5.0.
I opened a github ticket: https://github.com/jameslawler/react-native-rss-parser/issues/16
Right now you can use v1.4.0 of react-native-rss-parser to make it work.
yarn add react-native-rss-parser@1.4.0