Skip to content

Conversation

@pierpo
Copy link

@pierpo pierpo commented Nov 3, 2025

When we change pages, the useLink triggers a re-render (reason: context change) of all my components that use it (a lot -- I work on a media app).
Perf is drastically better when I memoize my components properly, but the missing useCallback on this onPress is a blocker for this.

Ideally, I'd love to have no re-render at all because the useLink does not trigger any context change (I didn't understand why it did). But that's a separate matter :)

@vercel
Copy link

vercel bot commented Nov 3, 2025

@pierpo is attempting to deploy a commit to the Fernando Rojo's projects Team on Vercel.

A member of the Team first needs to authorize it.

[router, href, replace, experimental],
)

return {
Copy link
Author

@pierpo pierpo Nov 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could also add a useMemo here, it might be useful because I have to add the following piece of code in my app haha

  const stableLinkProps = useMemo(
    () => ({
      onPress: linkProps.onPress,
      accessibilityRole: linkProps.accessibilityRole,
      href: linkProps.href,
    }),
    [linkProps.onPress, linkProps.accessibilityRole, linkProps.href],
  )

@nandorojo
Copy link
Owner

it might make sense to build the library with the react compiler

@pierpo
Copy link
Author

pierpo commented Nov 19, 2025

It would definitely make sense indeed 😁 I'm sure there are many other places where such optimizations would greatly help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants