Last active
January 4, 2017 07:51
-
-
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.
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
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