I looked through SO as much as possible for integrating a durations library into React, but can't find concrete examples in a React context. Sorry if this is a newbie question, I've been working and searching on this issue for a while through the momentjs issues and various other means.
I'm trying to work out how to call a duration method in React for a JS library using either humanize-duration or moment-duration-format. For instance, I try to call humanize-duration
in my component:
import React, { Fragment } from 'react'
import NumberFormat from 'react-number-format'
import humanizeDuration from 'humanize-duration';
export default function ProductDetails({ time_inventoried, total_time_staged }) {
return <tr>
<td>humanizeDuration({time_inventoried})</td> //860 days 03:34:17.564021 before format
<td>humanizeDuration({total_time_staged})</td> // # of seconds before format
</tr>
}
Trying to call this using typical instructions, as attempted above, renders only an unprocessed result in parentheses. What is the correct way to render this in React?