jameslawler / react-native-rss-parser

React Native compatible package to parse RSS feeds

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

_this.getElementTextContentArray is not a function

mrvndss opened this issue · comments

The given 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);
  });

results in this error:

_this.getElementTextContentArray is not a function. (In '_this.getElementTextContentArray(node, tagName, namespace)', '_this.getElementTextContentArray' is undefined)
- node_modules/react-native-rss-parser/parsers/utils.js:40:32 in exports.getElementTextContent
- node_modules/react-native-rss-parser/parsers/atomv1.js:5:6 in <global>
- node_modules/react-native-rss-parser/parsers/atomv1.js:135:9 in mapChannelFields
- node_modules/react-native-rss-parser/parsers/atomv1.js:169:8 in exports.parse
* http://127.0.0.1:19001/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&minify=false&hot=false:145220:35 in <unknown>
- node_modules/react-native/node_modules/promise/setimmediate/core.js:45:6 in tryCallTwo
- node_modules/react-native/node_modules/promise/setimmediate/core.js:200:22 in doResolve
- node_modules/react-native/node_modules/promise/setimmediate/core.js:66:11 in Promise
- node_modules/react-native-rss-parser/index.js:22:16 in exports.parse
- node_modules/react-native/node_modules/promise/setimmediate/core.js:37:13 in tryCallOne
- node_modules/react-native/node_modules/promise/setimmediate/core.js:123:24 in setImmediate$argument_0
- node_modules/react-native/Libraries/Core/Timers/JSTimers.js:130:14 in _callTimer
- node_modules/react-native/Libraries/Core/Timers/JSTimers.js:181:14 in _callImmediatesPass
- node_modules/react-native/Libraries/Core/Timers/JSTimers.js:441:30 in callImmediates
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:387:6 in __callImmediates
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:135:6 in __guard$argument_0
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:364:10 in __guard
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:134:4 in flushedQueue
* [native code]:null in flushedQueue
* [native code]:null in invokeCallbackAndReturnFlushedQueue

Update: It's working in v1.4.0

I just tried it out using expo as per your stack trace and it works fine for me.
I also just saw your edit saying that it works in v1.4.0 and so I will close this issue. 👍

Had the same issue here with version 1.5.0:
Solved changing the following lines of utils.js file.

Line 31 from:
const nodes = this.getChildElements(node, tagName, namespace);
to
const nodes = exports.getChildElements(node, tagName, namespace);

and line 41 from:
const array = this.getElementTextContentArray(node, tagName, namespace);
to
const array = exports.getElementTextContentArray(node, tagName, namespace);

I'm having same issue in 1.4.0 and 1.5.0.

Thanks for the fix from @julianbragachi
I have updated npm with v1.5.1