JavaScript How to convert react component to html string? convert react component to html,convert react component to pdf,

I have found similar to my issue here.

But I have a little bit different scenario. I have string of html rather than just string. So, I wanted to do:

Let's suppose MyComponent is just returning h3 element for now:

const MyComponent = ({children}) => (<h3>{children}</h3>)

var parts = "<h1>I</h1><p>am a cow;</p>cows say moo. MOOOOO."
    .split(/(\bmoo+\b)/gi);
for (var i = 1; i < parts.length; i += 2) {
  parts[i] = <MyComponent key={i}>{parts[i]}</MyComponent>;
}
// But I need html to be rendered
return <div dangerouslySetInnerHTML={{ __html: parts }} />

This will be rendered in the browser like this:

I
am a cow;
cows say ,[object Object],. ,[object Object],.

What I can think here to resolve the issue is converting component with string of html first.

parts[i] = convertToStringOfHtml(<MyComponent key={i}>{parts[i]}</MyComponent>);

But I don't have idea how to convert component to string of html.

Answer:1

I did some research on how to remove logo which removes the Vimeo logo on the bottom right corner. But I want to remove the user logo and author from embedded vimeo video. Is this possible? If yes how ...

I did some research on how to remove logo which removes the Vimeo logo on the bottom right corner. But I want to remove the user logo and author from embedded vimeo video. Is this possible? If yes how ...

  1. vimeo hide user

I have a pretty straightforward page in WordPress, which works fine outside the WordPress framework, but once I integrate it into a WordPress theme it refuses to re-size a element. The rest of the ...

I have a pretty straightforward page in WordPress, which works fine outside the WordPress framework, but once I integrate it into a WordPress theme it refuses to re-size a element. The rest of the ...

  1. dynamic image resizing javascript
  2. javascript dynamic resizing

I am trying to learn Angular JS with an HTML Sample. I would like the user to fill out some basic information, and based on the checkbox they select, it will load a form page using the UI Routing. It ...

I am trying to learn Angular JS with an HTML Sample. I would like the user to fill out some basic information, and based on the checkbox they select, it will load a form page using the UI Routing. It ...

  1. angularjs routing based on condition
  2. angularjs dynamic routing-based approach
  3. angularjs role based routing
  4. angularjs component based routing
  5. angularjs state based routing

I need to make a program that gets user input string. How to check if a spesific words with .includes() that can have capital leters?

I need to make a program that gets user input string. How to check if a spesific words with .includes() that can have capital leters?