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 badges2 Answers
Reset to default 4Use 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
评论列表(0条)