Skip to content

Document useProfiler hook for React Native component tracking #17304

@sentry-junior

Description

@sentry-junior

Summary

The useProfiler hook is a publicly exported, officially supported API in @sentry/react (re-exported by @sentry/react-native), but it has no documentation on the React Native component tracking page. Users who find it via source discovery have no way to confirm it's safe to rely on, what options it accepts, or how it differs from withProfiler.

Background

The current docs for React Native Component Tracking cover only withProfiler (HOC pattern). The useProfiler hook is a cleaner fit for modern function components — you drop useProfiler("MyComponent") inside the component body without rewiring exports — but it is entirely absent from the docs.

Source reference: profiler.tsx

Scope

  • Add useProfiler hook documentation to the React Native component tracking page (and the React page if it's also missing there)
  • Cover: usage example, accepted options (name, disabled, hasRenderSpan), and a brief comparison to withProfiler noting the trade-offs (hook = cleaner for function components; HOC = also tracks prop-change updates via updateProps)
  • Note the shared requirement: tracing must be configured (tracesSampleRate) or no spans are generated

Dependencies

Action taken on behalf of Chris Stavitsky.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions