Skip to content

Conversation

@abigailalexander
Copy link
Collaborator

With React 18, it seems some of the properties of the onRender callback have changed:

  • phase variable can now also be "nested-update", as well as "mount" and "update"
  • interactions variable has been removed

Without these changes, tsc fails in machine status and other clients with this error:

src/app.tsx:107:46 - error TS2322: Type '(id: string, phase: "mount" | "update", actualDuration: number, baseDuration: number, startTime: number, commitTime: number, interactions: unknown) => void' is not assignable to type 'ProfilerOnRenderCallback'.

107         <Profiler id="Dynamic Page Profiler" onRender={onRenderCallback}>

src/app.tsx:107:46 - error TS2322: Type '(id: string, phase: "mount" | "update", actualDuration: number, baseDuration: number, startTime: number, commitTime: number) => void' is not assignable to type 'ProfilerOnRenderCallback'.
  Types of parameters 'phase' and 'phase' are incompatible.
    Type '"mount" | "update" | "nested-update"' is not assignable to type '"mount" | "update"'.
      Type '"nested-update"' is not assignable to type '"mount" | "update"'.

107         <Profiler id="Dynamic Page Profiler" onRender={onRenderCallback}>

Copy link
Collaborator

@rjwills28 rjwills28 left a comment

Choose a reason for hiding this comment

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

Can confirm this fixes the errors so looks good!

@abigailalexander abigailalexander merged commit 379efc2 into master Jan 8, 2025
2 checks passed
@abigailalexander abigailalexander deleted the fix-profiler-callback branch January 8, 2025 13:06
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.

3 participants