Allow children to return HTML

Open
#890 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
javascript, react
Domain
tooling

Research direction

Start by reproducing the RSS example with reactElementToJSXString and inspect how child text containing HTML and CDATA is serialized. Determine the expected output for HTML children and verify the behavior with a focused regression test; done means the generated JSX preserves the requested child representation without the current string transformation.

Written by the indexing model from the issue text.

Description

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?

Dominant language
TypeScript
Stars
519
Forks
88
Avg merge
3h 55m
Merged PRs (30d)
1

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from algolia/react-element-to-jsx-string

All issues in algolia/react-element-to-jsx-string

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.