I'm new to the ReactJS framework and I have these lines of code:
//rest of code omitted...
const dateToTime = date => date.toLocaleString('en-GB');
const dateString = `${order.data.created_at}Z`;
const localDate = new Date(dateString);
The other part of the code is inserted in that part of the component. The code is working perfectly.
//rest of code omitted...
return (
<React.Fragment key={index}>
<td>{dateToTime(localDate) || emptyMessage}</td> //<-----code continuation
//rest of code omitted...
I would like to do a utility function to import into various components, How do I do this?
I want to reuse the code