Skip to content

Commit a47ec76

Browse files
billyvgAhmed-Labs
authored andcommitted
fix(ui): moment deprecated date formatting in useFlagSeries() (#102874)
This fixes the following console.warn that we are getting in prod: ``` Deprecation warning: value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info. Arguments: ``` We were calling `moment()` with a formatted date string, instead, we can use unix timestamp.
1 parent a36cd5b commit a47ec76

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

static/app/components/featureFlags/hooks/useFlagSeries.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@ export function useFlagSeries({event, flags}: FlagSeriesProps) {
4848
}
4949
);
5050

51-
const eventIsBefore = moment(event?.dateCreated).isBefore(moment(time));
52-
const formattedDate = moment(time).from(event?.dateCreated, true);
51+
const timeObject = moment(data.xAxis);
52+
const eventIsBefore = moment(event?.dateCreated).isBefore(timeObject);
53+
const formattedDate = timeObject.from(event?.dateCreated, true);
5354
const suffix = eventIsBefore
5455
? t(' (%s after this event)', formattedDate)
5556
: t(' (%s before this event)', formattedDate);

0 commit comments

Comments
 (0)