PositiveGuy PositiveGuy - 2 months ago 15
React JSX Question

Returning RSS from React Component

I'm not sure how to resolve this. I get syntax errors in WebStorm when I try to return the first line.

const Feed = Component({
render() {
return (
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Test</title>
<link>test</link>
<description>test</description>
<item>
<title>test</title>
<link>test</link>
<guid>test</guid>
<pubDate>Tues, 23 Aug 2016 10:00:00 CDT</pubDate>
<description>test</description>
</item>
</channel>
</rss>
);
}
})

export default Feed


For something React doesn't like the syntax
<?xml version="1.0" encoding="utf-8"?>
because it doesn't recognize what

Answer

Yes, React doesn't recognize xml. So, you need to convert your xml to string and put it under <pre> tag to preserve the indents.

Working fiddle: https://jsfiddle.net/Pranesh456/qt2bp9oe/3/