Next.js Discord

Discord Forum

default export with memo() in React

Unanswered
European anchovy posted this in #help-forum
Open in Discord
Avatar
European anchovyOP
If I use the default 1 export option, will memo() memoize the component correctly?

// 1
export default memo(function Component() {
  return (
    <div>Component</div>
  )
})


// 2
const Component = memo(function Component() {
  return (
    <div>Component</div>
  )
})

export default Component

1 Reply

Avatar
Asian black bear
yeah it should, use the react dev tools with re-render highlights enabled to confirm.
ctrl-clicking into a memoized component in vscode isn't as seamless for me but it does work