From c07543c8c3ff7cb70438d6f26c542b2446062730 Mon Sep 17 00:00:00 2001 From: Abhijeet Prasad Date: Thu, 25 Jun 2020 15:11:42 -0400 Subject: [PATCH 1/3] ref: Change Profiler prop names --- packages/react/src/profiler.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/react/src/profiler.tsx b/packages/react/src/profiler.tsx index 8ef7d6966f63..6df4ae69e798 100644 --- a/packages/react/src/profiler.tsx +++ b/packages/react/src/profiler.tsx @@ -83,9 +83,9 @@ export type ProfilerProps = { // in certain environments. disabled?: boolean; // If time component is on page should be displayed as spans. True by default. - hasRenderSpan?: boolean; + includeRender?: boolean; // If component updates should be displayed as spans. True by default. - hasUpdateSpan?: boolean; + includeUpdates?: boolean; // props given to component being profiled. updateProps: { [key: string]: any }; }; From 402ca4c41f7132f29e25301fe7c1f02c37a57653 Mon Sep 17 00:00:00 2001 From: Abhijeet Prasad Date: Thu, 25 Jun 2020 15:16:14 -0400 Subject: [PATCH 2/3] ref: Change React Profiler prop names: --- packages/react/src/profiler.tsx | 12 ++++++------ packages/react/test/profiler.test.tsx | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/react/src/profiler.tsx b/packages/react/src/profiler.tsx index 6df4ae69e798..2af9dbaab86d 100644 --- a/packages/react/src/profiler.tsx +++ b/packages/react/src/profiler.tsx @@ -104,8 +104,8 @@ class Profiler extends React.Component { public static defaultProps: Partial = { disabled: false, - hasRenderSpan: true, - hasUpdateSpan: true, + includeRender: true, + includeUpdates: true, }; public constructor(props: ProfilerProps) { @@ -130,11 +130,11 @@ class Profiler extends React.Component { this.mountActivity = null; } - public componentDidUpdate({ updateProps, hasUpdateSpan = true }: ProfilerProps): void { + public componentDidUpdate({ updateProps, includeUpdates = true }: ProfilerProps): void { // Only generate an update span if hasUpdateSpan is true, if there is a valid mountSpan, // and if the updateProps have changed. It is ok to not do a deep equality check here as it is expensive. // We are just trying to give baseline clues for further investigation. - if (hasUpdateSpan && this.mountSpan && updateProps !== this.props.updateProps) { + if (includeUpdates && this.mountSpan && updateProps !== this.props.updateProps) { // See what props haved changed between the previous props, and the current props. This is // set as data on the span. We just store the prop keys as the values could be potenially very large. const changedProps = Object.keys(updateProps).filter(k => updateProps[k] !== this.props.updateProps[k]); @@ -158,9 +158,9 @@ class Profiler extends React.Component { // If a component is unmounted, we can say it is no longer on the screen. // This means we can finish the span representing the component render. public componentWillUnmount(): void { - const { name, hasRenderSpan = true } = this.props; + const { name, includeRender = true } = this.props; - if (this.mountSpan && hasRenderSpan) { + if (this.mountSpan && includeRender) { // If we were able to obtain the spanId of the mount activity, we should set the // next activity as a child to the component mount activity. this.mountSpan.startChild({ diff --git a/packages/react/test/profiler.test.tsx b/packages/react/test/profiler.test.tsx index 0da9d9545099..60c2fd312349 100644 --- a/packages/react/test/profiler.test.tsx +++ b/packages/react/test/profiler.test.tsx @@ -120,7 +120,7 @@ describe('withProfiler', () => { }); it('is not created if hasRenderSpan is false', () => { - const ProfiledComponent = withProfiler(() =>

Testing

, { hasRenderSpan: false }); + const ProfiledComponent = withProfiler(() =>

Testing

, { includeRender: false }); expect(mockStartChild).toHaveBeenCalledTimes(0); const component = render(); @@ -165,7 +165,7 @@ describe('withProfiler', () => { it('does not get created if hasUpdateSpan is false', () => { const ProfiledComponent = withProfiler((props: { num: number }) =>
{props.num}
, { - hasUpdateSpan: false, + includeUpdates: false, }); const { rerender } = render(); expect(mockStartChild).toHaveBeenCalledTimes(0); From 9f26825002f5945cc233bd8c187fb8ec237ccd69 Mon Sep 17 00:00:00 2001 From: Abhijeet Prasad Date: Thu, 25 Jun 2020 16:01:02 -0400 Subject: [PATCH 3/3] CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1fa7d637cf48..e9ddb3edb52e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - "You miss 100 percent of the chances you don't take. — Wayne Gretzky" — Michael Scott - [react] feat: Update peer dependencies for `react` and `react-dom` (#2694) +- [react] ref: Change Profiler prop names (#2699) ## 5.18.0