Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I convert React Element to Html element?

Now I've using ag-Grid that can create custom renderer for each data cells but it's required Html elements

For example they're an Elements that can be created by calling document.createElement()

But I want to use React element as custom renderer for my convenient

Don't sure that I can do that or not ?

like image 590
Ittipon Teerapruettikulchai Avatar asked Jul 06 '16 10:07

Ittipon Teerapruettikulchai


People also ask

Can I convert React to HTML?

Yes, both Angular and React apps can be (and usually are) "built" to static HTML, CSS and JS.

Can HTML replace React with CSS?

What makes React such a desirable library to learn is that it doesn't replace HTML. It takes advantage of HTML's popularity and strength as the most popular programming language, by letting you use a very similar syntax to HTML to build interfaces and add dynamic features to it using JavaScript.

How integrate with React in HTML?

There may be an instance where you would want to display HTML inside a React Component. The HTML could be from an external source or a file that you want to display to the user. By default, React does not permit you to inject HTML in a component, for various reasons including cross-site scripting.


1 Answers

You can try to use getDOMNode for example: this.refs.giraffe.getDOMNode(), or:

import ReactDOM from 'react-dom';
...
const submitBtn = ReactDOM.findDOMNode(this.refs.submitButton)

But that way has some deprecation issues, more here: React.js: The difference between findDOMNode and getDOMNode

like image 64
steppefox Avatar answered Sep 25 '22 22:09

steppefox