Skip to content

Instantly share code, notes, and snippets.

@jamilalisgandarov
Created October 8, 2020 13:44
Show Gist options
  • Save jamilalisgandarov/826f7e594841d53bb915e4890d78041d to your computer and use it in GitHub Desktop.
Save jamilalisgandarov/826f7e594841d53bb915e4890d78041d to your computer and use it in GitHub Desktop.

Revisions

  1. Jamil Alisgandarov created this gist Oct 8, 2020.
    12 changes: 12 additions & 0 deletions useMemo.ts
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    const Component: React.FC = ({ listOfItems,first,second }) => {
    const list = useMemo(
    () => listOfItems.map(item => ({
    ...item,
    itemProp1: expensiveFunction(first),
    itemProp2: anotherPriceyFunction(second)
    })),
    [listOfItems]
    )

    return // render list as you wish
    }