Advertisement
deddyprianto

FUNCTION SORT DATE with Object.asssign

Jan 4th, 2022
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const [data, setData] = useState(dataArr);
  2. const fnMostRecent = () => {
  3.     let arr2 = [];
  4.     const data2 = Object.assign(arr2, data);
  5.     setData(data2.sort((a, b) => new Date(b.date) - new Date(a.date)));
  6.   };
  7.  
  8.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement