简体   繁体   中英

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 ?

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

There's a new React way in ag-grid for this purpose. It's quite recent so you have to update your ag-grid module. Instead of using cellRenderer use cellRendererFactory to which you can pass React component directly. Source: https://www.ag-grid.com/javascript-grid-cell-rendering-components/#react-cell-rendering

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM