Workaround for custom attributes in JSX
https://github.com/facebook/react/issues/140
by peterjmag
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.13.1/JSXTransformer.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.13.1/react-with-addons.js"></script>
<script src="https://facebook.github.io/react/js/jsfiddle-integration.js"></script>
<div id="container">
<!-- This element's contents will be replaced with your component. -->
</div>
JavaScript 1.7
var Hello = React.createClass({
componentDidMount: function() {
this.refs.test.getDOMNode().setAttribute('custom-attribute', 'some value');
},
render: function() {
return <div>
<span ref="test">Element with a custom attribute</span>
</div>;
}
});
React.render(<Hello />, document.getElementById('container'));