简体   繁体   English

如何将React元素转换为Html元素?

[英]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 现在我使用的ag-Grid可以为每个数据单元创建自定义渲染器,但它是必需的Html元素

For example they're an Elements that can be created by calling document.createElement() 例如,它们是可以通过调用document.createElement()创建的元素。

But I want to use React element as custom renderer for my convenient 但我想使用React元素作为自定义渲染器,方便我

Don't sure that I can do that or not ? 不确定我能做到吗?

You can try to use getDOMNode for example: this.refs.giraffe.getDOMNode() , or: 您可以尝试使用getDOMNode ,例如: this.refs.giraffe.getDOMNode()或:

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 但是这种方式有一些弃用问题,更多这里: React.js:findDOMNode和getDOMNode之间的区别

There's a new React way in ag-grid for this purpose. 为此目的,在ag-grid中有一种新的React方式。 It's quite recent so you have to update your ag-grid module. 这是最近的,所以你必须更新您的ag-grid模块。 Instead of using cellRenderer use cellRendererFactory to which you can pass React component directly. 而不是使用cellRenderer使用cellRendererFactory ,您可以直接传递React组件。 Source: https://www.ag-grid.com/javascript-grid-cell-rendering-components/#react-cell-rendering 资料来源: https//www.ag-grid.com/javascript-grid-cell-rendering-components/#react-cell-rendering

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将一个 html 元素转换为另一个元素? - How can I convert one html element to another element? 我怎样才能 append 一个 React 组件到一个 html 元素我? - How can I append a React component to an html element i? JS:如何将 HTML 元素转换为 PDF - JS: How Can I Convert HTML Element Into A PDF 如何在功能性反应组件中操作 html 元素的样式? - how can i manipulate style of a html element in functional react component? 当用户触摸iPhone上的HTML元素时,我该如何反应? - How can I react when a user touches an HTML element on an iPhone? 使用React Router,如何为HTML元素分配一个类? - With React Router, how can I assign a class to the HTML element? 如何将XML DOM元素转换为HTML DOM元素? - How do I convert an XML DOM element into an HTML DOM element? 如何将现有的DOM元素文本转换为HTML元素? - How do I convert existing DOM element text to HTML element? 如何在不使用第三方库的情况下将 html 字符串转换为反应元素? - How do I convert a html string into a react element without using a third party library? 如何将 html 元素的 Json object 转换为我可以使用 C# 或 js 或 jquery 在视图上呈现的实际 HTML 元素 - How to convert Json object of html element into actual HTML element that i can render on view using C# or js or jquery
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM