Skip to content

Allow children to return HTML #890

Description

@jpmonette

I'm trying to generate RSS feed using reactElementToJSXString from a React element.

When I try to render the content of the blog post, it should look something like this:

<codearea>
  <![CDATA[ 
  <div> <p> my para </p> </div> 
  ]]>
</description>

However, it seems like all the HTML is transformed into a string:

<description>
{`<![CDATA[<div> <p> my para </p> </div> ]]>`}
</description>

My React code:

import type { JSONFeed } from "./feed-type";

export const RSS = (feed: JSONFeed) => (
  <rss version="2.0">
    <channel>
      {feed.items?.map((item) => {
        return (
          <item>
            <description>{`<![CDATA[${item.content_text}]]>`}</description>
          </item>
        );
      })}
    </channel>
  </rss>
);

Is it possible to have it rendered without being turned into a string?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions