React with jQuery UI Datepicker

React with jQuery UI Datepicker

by wiredprairie

HTML

<script src="http://fb.me/JSXTransformer-0.12.1.js"></script>
<script src="http://fb.me/react-with-addons-0.12.1.js"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script src="http://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

// In personal projects, jQuery UI Datepicker in React simply doesn't render or even throw

var DateInput = React.createClass({
    render: function() {
        return <input type="text" className="datepicker" />;
    }
});

var Calendar = React.createClass({
    componentDidMount: function() {
        $('.datepicker').datepicker();
    },
    render: function() {
        return ( 
            <form>
                <DateInput />                
                <div>
                    If you just use Date...here's what happens:
                    <br/>
                    <Date/>
                </div>
            </form>
        )
    }
});
 
React.render(<Calendar />, document.body);