How to use Props with Generics with React.memo

前端 未结 4 1151
感动是毒
感动是毒 2021-01-21 15:09

I am trying to convert the following to use React.memo:

interface Props {
  // props...
}

export function Table({
          


        
4条回答
  •  青春惊慌失措
    2021-01-21 15:48

    Don't you need to pass a component as the first parameter of React.memo? I couldn't test it, but I feel like this is the thought process:

    // Overall format:
    export const Table = memo(MyComponent, MyFunction)
    
    // With empty arrow function:
    export const Table = memo(MyComponent, () => {})
    
    // With your code:
    export const Table = memo(MyComponent, ({propA, propB}: Props) => {
    
    })
    

提交回复
热议问题