javascript - How to printlog reactjs rendered dom? - Stack Overflow

I'm creating a ponent with ReactJS. I would see the html react renders with my console, so for exa

I'm creating a ponent with ReactJS.

I would see the html react renders with my console, so for example:

 import React, { PropTypes } from 'react';
 import ReactDOM from 'react-dom';

 class CustomComponent extends React.Component {


   render() { return (<div>Custom</div>); }
 }

And instead of:

ReactDOM.render(<CustomComponent />, document.getElementById('app'));

I would do something like:

console.log(<CustomComponent />); 

but when in my console I call:

babel-node myfile.js

I get:

How can I print/log the effective html tags that react renders?

thanks. bye.

I'm creating a ponent with ReactJS.

I would see the html react renders with my console, so for example:

 import React, { PropTypes } from 'react';
 import ReactDOM from 'react-dom';

 class CustomComponent extends React.Component {


   render() { return (<div>Custom</div>); }
 }

And instead of:

ReactDOM.render(<CustomComponent />, document.getElementById('app'));

I would do something like:

console.log(<CustomComponent />); 

but when in my console I call:

babel-node myfile.js

I get:

How can I print/log the effective html tags that react renders?

thanks. bye.

Share Improve this question asked Dec 15, 2015 at 11:46 baudo2048baudo2048 1,1523 gold badges14 silver badges27 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

Use https://facebook.github.io/react/docs/top-level-api.html#reactdomserver.rendertostring

Now you're just printing the virtual dom representation which need to be transformed to string.

you need to use string renderToStaticMarkup(ReactElement element)

it will return you the StaticMarkup

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744231584a4564279.html

相关推荐

  • javascript - How to printlog reactjs rendered dom? - Stack Overflow

    I'm creating a ponent with ReactJS. I would see the html react renders with my console, so for exa

    8天前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信