admin管理员组文章数量:1401630
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 ?
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 ?
Share Improve this question asked Jul 6, 2016 at 10:19 Ittipon TeerapruettikulchaiIttipon Teerapruettikulchai 4755 silver badges22 bronze badges 2-
1
So if I got it right, you are creating a custom cell renderer like this:
cellRenderer: reactCellRendererFactory(MyCustomCellRenderer)
, right? And your question is if you can use React ponents in the jsx that the render method of MyCustomCellRenderer ponent returns? – Smilev Commented Jul 6, 2016 at 13:55 - @Smilev, that is exactly what I'd like to know. At the very least, it seems that cannot be done in the function version of a cell renderer, Can that be done in the ponent form of the cellRenderer? – dsh Commented Aug 28, 2016 at 6:08
2 Answers
Reset to default 2You 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 ponent directly. Source: https://www.ag-grid./javascript-grid-cell-rendering-ponents/#react-cell-rendering
本文标签: javascriptHow can I convert React Element to Html elementStack Overflow
版权声明:本文标题:javascript - How can I convert React Element to Html element? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744285211a2598846.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论