Created
May 15, 2016 02:15
-
-
Save alanbsmith/de82e9b747b32b4622a0fc7ffe5afa05 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import ReactDOM from 'react-dom'; | |
// import SomeComponent from './components/SomeComponent'; | |
// import AnotherComponent from './components/AnotherComponent'; | |
const components = { | |
// Your components go here: | |
// 'SomeComponent': SomeComponent, | |
// 'AnotherComponent': AnotherComponent | |
} | |
const reactTargetDivs = document.getElementsByClassName('react-component-target'); | |
let componentName, componentProps | |
Array.prototype.forEach.call(reactTargetDivs, function (targetDiv) { | |
componentName = targetDiv.getAttribute('data-react-class') | |
componentProps = JSON.parse(targetDiv.getAttribute('data-react-props')) | |
ReactDOM.render( | |
React.createElement( | |
components[componentName], | |
componentProps | |
), | |
targetDiv | |
) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment