How to use react-timeago - 10 common examples

To help you get started, we’ve selected a few react-timeago 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 insin / react-hn / src / UserProfile.js View on Github external
var React = require('react')
var ReactFireMixin = require('reactfire')
var TimeAgo = require('react-timeago').default

var HNService = require('./services/HNService')

var Spinner = require('./Spinner')

var setTitle = require('./utils/setTitle')

// TODO User submissions

// TODO User comments

var UserProfile = React.createClass({
  mixins: [ReactFireMixin],
  getInitialState() {
    return {user: {}}
  },
github insin / react-hn / src / mixins / CommentMixin.js View on Github external
var React = require('react')
var Link = require('react-router/lib/Link')
var TimeAgo = require('react-timeago').default

var ItemStore = require('../stores/ItemStore')
var SettingsStore = require('../stores/SettingsStore')

var Spinner = require('../Spinner')

var pluralise = require('../utils/pluralise')

var CommentMixin = {
  fetchAncestors(comment) {
    ItemStore.fetchCommentAncestors(comment, result => {
      if (process.env.NODE_ENV !== 'production') {
        console.info(
          'fetchAncestors(' + comment.id + ') took ' +
          result.timeTaken + ' ms for ' +
          result.itemCount + ' item' + pluralise(result.itemCount) + ' with ' +
github insin / react-hn / src / mixins / ItemMixin.js View on Github external
var React = require('react')
var Link = require('react-router/lib/Link')
var TimeAgo = require('react-timeago').default

var SettingsStore = require('../stores/SettingsStore')
var pluralise = require('../utils/pluralise')
var urlParse = require('url-parse')

var parseHost = function(url) {
  var hostname = (urlParse(url, true)).hostname
  var parts = hostname.split('.').slice(-3)
  if (parts[0] === 'www') {
    parts.shift()
  }
  return parts.join('.')
}

/**
 * Reusable logic for displaying an item.
github tronscan / tronscan-frontend / src / components / common / TimeAgoI18N.js View on Github external
const TimeAgoI18N = ({date, activeLanguage}) => {
    const formatter = buildFormatter(timeLanguages[activeLanguage]);
    return ;
};
github nowyasimi / no8am / no8am / static / js / filters / GlobalFilters.tsx View on Github external
public render() {
        const formatter = buildFormatter(englishStrings);

        const cacheTime = new Date();

        return (
            <div>
                
                </div>
        );
    }
}
github fuhcm / fptu-app / src / app / modules / search / Search.js View on Github external
Row,
  Col,
  Statistic,
  Icon,
  Card,
} from "antd";
import Helmet from "react-helmet-async";
import Highlighter from "react-highlight-words";
import { debounce } from "debounce";
import styled from "styled-components";

import TimeAgo from "react-timeago";
import viStrings from "react-timeago/lib/language-strings/vi";
import buildFormatter from "react-timeago/lib/formatters/buildFormatter";

const formatter = buildFormatter(viStrings);

const { Content } = Layout;
const Search = Input.Search;

const ConfessContent = styled.div`
  white-space: pre-line;
`;

class SearchPage extends PureComponent {
  state = {
    initLoading  : true,
    loading      : false,
    data         : [],
    list         : [],
    isSearchMode : false,
    searchKeyword: "",
github ICTU / quality-report / frontend / js / components / last_built_label.js View on Github external
render() {
        const formatter = buildFormatter(dutchStrings);

        var year = this.props.latest_change_date ?
                   parseInt(this.props.latest_change_date.substr(0, 4), 10) : 0;

        if (year &gt; 2000) {
            return (
                <span>
                    gewijzigd 
                </span>
            );
        }
        return '';
    }
}
github bukinoshita / hackdisrupt / pages / polls / index.js View on Github external
render() {
    const formatter = buildFormatter(brazilianStrings)
    const { polls } = this.state
    const token = getCookie('hackdisrupt')

    const createNewBtn = token ? (
      
        <button size="small">criar uma poll</button>
      
    ) : (
      undefined
    )

    const list = polls ? (
      polls.map(({ _id, owner, createdAt, title, description }) =&gt; {
        return (
          <li>
            </li>
github huacnlee / bluedoc / app / javascript / bluebox / timeago / index.js View on Github external
month: '大约 1 个月',
  months: '%d 月',
  year: '大约 1 年',
  years: '%d 年',

  wordSeparator: ''
};

const metaLocale = document.querySelector('meta[name=locale]');
let locale = "en";
if (metaLocale) {
  locale = metaLocale.getAttribute("content");
}
let formatter;
if (locale === "zh-CN") {
  formatter = buildFormatter(cnStrings)
} else {
  formatter = buildFormatter(enStrings)
}



export class Timeago extends React.Component {
  render() {
    let { value, time } = this.props;
    if (!value) {
      value = time;
    }

    return 
  }
}
github fuhcm / fptu-app / src / app / modules / change / Change.js View on Github external
Layout,
  message,
  Progress,
  List,
  Skeleton,
  Card,
} from "antd";
import GoogleLogin from "react-google-login";

import TimeAgo from "react-timeago";
import viStrings from "react-timeago/lib/language-strings/vi";
import buildFormatter from "react-timeago/lib/formatters/buildFormatter";

const { Content } = Layout;

const formatter = buildFormatter(viStrings);

function ChangeForm() {
  const [loading, setLoading] = useState(false);
  const [isSigned, setIsSigned] = useState(false);
  const [signList, setSignList] = useState([]);
  const [count, setCount] = useState(0);

  useEffect(() => {
    let fake = null;

    setLoading(true);
    FPTUSDK.change
      .getSignList()
      .then(data => {
        setSignList(data.list);
        setCount(data.count || 0);

react-timeago

A simple Time-Ago component for ReactJs

MIT
Latest version published 1 year ago

Package Health Score

64 / 100
Full package analysis