Forward Ref Stub

This commit is contained in:
Chi Vinh Le
2018-07-17 15:23:16 -03:00
parent 7b929c356e
commit de739554c8
13 changed files with 134 additions and 25 deletions
@@ -1,9 +1,9 @@
import cn from "classnames";
import React from "react";
import React, { Ref } from "react";
import TimeAgo, { Formatter } from "react-timeago";
import { UIContext } from "talk-ui/components";
import { withStyles } from "talk-ui/hocs";
import { withForwardRef, withStyles } from "talk-ui/hocs";
import { PropTypesOf } from "talk-ui/types";
import * as styles from "./RelativeTime.css";
@@ -14,6 +14,12 @@ interface InnerProps {
classes: typeof styles;
className?: string;
formatter?: Formatter;
/** Ref to the root element */
ref?: Ref<HTMLDivElement>;
/** Internal: Forwarded Ref */
forwardRef?: Ref<HTMLDivElement>;
}
const defaultFormatter: Formatter = (value, unit, suffix, timestamp: string) =>
@@ -37,6 +43,6 @@ class RelativeTime extends React.Component<InnerProps> {
}
}
const enhanced = withStyles(styles)(RelativeTime);
const enhanced = withForwardRef(withStyles(styles)(RelativeTime));
export type RelativeTimeProps = PropTypesOf<typeof enhanced>;
export default enhanced;