Package Exports
- react-render-to-json
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 (react-render-to-json) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
react-render-to-json
hacky way to figure out what is passed to this.props.children in react
install
npm install react-render-to-json --save
usage example
import React from 'react';
import renderToJson from 'react-render-to-json';
class Heart extends React.Component {
render() {
return (
<svg width="24" fill="#00ea00" height="24" viewBox="0 0 24 24">
<g><path d="M12 10.375c0-2.416-1.959-4.375-4.375-4.375s-4.375 1.959-4.375 4.375c0 1.127.159 2.784 1.75 4.375l7 5.25s5.409-3.659 7-5.25 1.75-3.248 1.75-4.375c0-2.416-1.959-4.375-4.375-4.375s-4.375 1.959-4.375 4.375"/></g>
</svg>
);
}
}
console.log(renderToJSon(<Heart />));
{
"name": "Heart",
"attributes": {},
"children": [{
"name": "svg",
"attributes": {
"width": "24",
"fill": "#00ea00",
"height": "24",
"viewBox": "0 0 24 24"
},
"children": [{
"name": "g",
"attributes": {},
"children": [{
"name": "path",
"attributes": {
"d": "M12 10.375c0-2.416-1.959-4.375-4.375-4.375s-4.375 1.959-4.375 4.375c0 1.127.159 2.784 1.75 4.375l7 5.25s5.409-3.659 7-5.25 1.75-3.248 1.75-4.375c0-2.416-1.959-4.375-4.375-4.375s-4.375 1.959-4.375 4.375"
}
}]
}]
}]
}
Used by react-svg-morph
Licence
MIT