Skip to content

Commit b011546

Browse files
authored
ref: Change Profiler prop names (#2699)
* ref: Change Profiler prop names * ref: Change React Profiler prop names: * CHANGELOG
1 parent 45f1bb4 commit b011546

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
- "You miss 100 percent of the chances you don't take. — Wayne Gretzky" — Michael Scott
66
- [react] feat: Update peer dependencies for `react` and `react-dom` (#2694)
7+
- [react] ref: Change Profiler prop names (#2699)
78

89
## 5.18.0
910

packages/react/src/profiler.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ export type ProfilerProps = {
8383
// in certain environments.
8484
disabled?: boolean;
8585
// If time component is on page should be displayed as spans. True by default.
86-
hasRenderSpan?: boolean;
86+
includeRender?: boolean;
8787
// If component updates should be displayed as spans. True by default.
88-
hasUpdateSpan?: boolean;
88+
includeUpdates?: boolean;
8989
// props given to component being profiled.
9090
updateProps: { [key: string]: any };
9191
};
@@ -104,8 +104,8 @@ class Profiler extends React.Component<ProfilerProps> {
104104

105105
public static defaultProps: Partial<ProfilerProps> = {
106106
disabled: false,
107-
hasRenderSpan: true,
108-
hasUpdateSpan: true,
107+
includeRender: true,
108+
includeUpdates: true,
109109
};
110110

111111
public constructor(props: ProfilerProps) {
@@ -130,11 +130,11 @@ class Profiler extends React.Component<ProfilerProps> {
130130
this.mountActivity = null;
131131
}
132132

133-
public componentDidUpdate({ updateProps, hasUpdateSpan = true }: ProfilerProps): void {
133+
public componentDidUpdate({ updateProps, includeUpdates = true }: ProfilerProps): void {
134134
// Only generate an update span if hasUpdateSpan is true, if there is a valid mountSpan,
135135
// and if the updateProps have changed. It is ok to not do a deep equality check here as it is expensive.
136136
// We are just trying to give baseline clues for further investigation.
137-
if (hasUpdateSpan && this.mountSpan && updateProps !== this.props.updateProps) {
137+
if (includeUpdates && this.mountSpan && updateProps !== this.props.updateProps) {
138138
// See what props haved changed between the previous props, and the current props. This is
139139
// set as data on the span. We just store the prop keys as the values could be potenially very large.
140140
const changedProps = Object.keys(updateProps).filter(k => updateProps[k] !== this.props.updateProps[k]);
@@ -158,9 +158,9 @@ class Profiler extends React.Component<ProfilerProps> {
158158
// If a component is unmounted, we can say it is no longer on the screen.
159159
// This means we can finish the span representing the component render.
160160
public componentWillUnmount(): void {
161-
const { name, hasRenderSpan = true } = this.props;
161+
const { name, includeRender = true } = this.props;
162162

163-
if (this.mountSpan && hasRenderSpan) {
163+
if (this.mountSpan && includeRender) {
164164
// If we were able to obtain the spanId of the mount activity, we should set the
165165
// next activity as a child to the component mount activity.
166166
this.mountSpan.startChild({

packages/react/test/profiler.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ describe('withProfiler', () => {
120120
});
121121

122122
it('is not created if hasRenderSpan is false', () => {
123-
const ProfiledComponent = withProfiler(() => <h1>Testing</h1>, { hasRenderSpan: false });
123+
const ProfiledComponent = withProfiler(() => <h1>Testing</h1>, { includeRender: false });
124124
expect(mockStartChild).toHaveBeenCalledTimes(0);
125125

126126
const component = render(<ProfiledComponent />);
@@ -165,7 +165,7 @@ describe('withProfiler', () => {
165165

166166
it('does not get created if hasUpdateSpan is false', () => {
167167
const ProfiledComponent = withProfiler((props: { num: number }) => <div>{props.num}</div>, {
168-
hasUpdateSpan: false,
168+
includeUpdates: false,
169169
});
170170
const { rerender } = render(<ProfiledComponent num={0} />);
171171
expect(mockStartChild).toHaveBeenCalledTimes(0);

0 commit comments

Comments
 (0)