Package Exports
- jsx-to-string
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (jsx-to-string) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
jsx-to-string
Parse your React JSX components to string
Install
npm install jsx-to-string
Usage
import React from 'react';
import jsxToString from 'jsx-to-string';
let Basic = React.createClass({
render() {
return (
<div />
);
}
}); //this is your react component
console.log(jsxToString(<Basic test1="test" />)); //outputs: <Basic test1="test" />
Options
- Function Value
The default value for function props is `...`.
This key allows to replace `...` by custom variable names, for example:
import React from 'react';
import jsxToString from 'jsx-to-string';
let Basic = React.createClass({
render() {
return (
<div />
);
}
}); //this is your react component
let _onClickHandler = function () {
//no-op
}
console.log(jsxToString(<Basic onClick={_onClickHandler} />, {
functionValue: {
onClick: '_onClickHandler'
}
})); //outputs: <Basic onClick={_onClickHandler} />