Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kenmori/99c2fda06eebdcf022472948956eb1a8 to your computer and use it in GitHub Desktop.
Save kenmori/99c2fda06eebdcf022472948956eb1a8 to your computer and use it in GitHub Desktop.
how to create React element where put on multiple places using the className of div elements instead of an id.
function renderToElements(elements) {
Array.prototype.slice.call(elements).forEach(function(e, i){
React.render(<FavoriteFortune id={e.dataset.id} isFavorite={true} />, e);
})
}
renderToElements(document.getElementsByClassName('favoriteFortune'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment