How to use the react-tools/build/modules/react.createClass function in react-tools

To help you get started, we’ve selected a few react-tools examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github andreypopp / react-time / index.jsx View on Github external
/**
 * @jsx React.DOM
 */

var datetime = require('datetime');
var React = require('react-tools/build/modules/react');

module.exports = React.createClass({
  render: function() {
    var value = this.props.value,
        machineReadable,
        humanReadable,
        formatter;

    if (Object.prototype.toString.call(value) == '[object String]') {
      value = new Date(value);
    }

    machineReadable = datetime.format(value, "%Y-%m-%dT%H:%M:%S");

    if (this.props.relative || this.props.format) {
      formatter = this.props.relative ? datetime.formatAgo : datetime.format;
      humanReadable = formatter(value, this.props.format);
      return this.transferPropsTo(<time datetime="{machineReadable}">{humanReadable}</time>);