Created
May 16, 2014 23:48
-
-
Save llkats/0e378ca0bd702435fb87 to your computer and use it in GitHub Desktop.
dynamic react element creation!
This file contains hidden or 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
var tagname = 'p'; | |
var aView = React.createClass({ | |
render: function() { | |
return React.DOM[tagname]({}, 'here is some content'); | |
} | |
}); |
@tameraydin I couldn't figure how to do this in JSX, but the cool thing about JSX is you can interchange JSX with raw JS whenever you like; so this is valid, for example:
(
<div>
{React.DOM[tagname](null, "here is some content")}
</div>
)
and this:
(
<div>
{
React.DOM[tagname](null,
"here is some content",
<p>Some more content</p>
)
}
</div>
)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
do you know if it is possible to accomplish this in JSX syntax?