1
0
mirror of synced 2025-12-22 03:16:52 -05:00
Files
docs/react/RedContent.js
Chiedo b781e43893 Add experimental react support within markdown
Also added fronmatter for interactive: true to turn on React on a file by file
basis and prevent slowing down the builds for non-react files
2020-10-18 14:44:34 -04:00

22 lines
535 B
JavaScript

const React = require('react')
const ReactDOM = require('react-dom')
const RedContent = (props) => {
return (
<div style={{ color: 'red' }}>
{props.children}
</div>
)
}
if (typeof window === 'undefined') {
} else {
const componentContainers = document.querySelectorAll('.react-component-RedContent')
for (const componentContainer of componentContainers) {
ReactDOM.render(React.createElement(RedContent, {}, componentContainer.children[0].innerText), componentContainer)
}
}
module.exports = RedContent