Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor UNSAFE_componentWillReceiveProps to use componentDidUpdate #612

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions packages/jaeger-ui/src/components/App/Page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,9 @@ export class PageImpl extends React.Component<TProps> {
trackPageView(pathname, search);
}

// eslint-disable-next-line camelcase
UNSAFE_componentWillReceiveProps(nextProps: TProps) {
const { pathname, search } = this.props;
const { pathname: nextPathname, search: nextSearch } = nextProps;
componentDidUpdate(prevProps: Readonly<TProps>) {
const { pathname, search } = prevProps;
const { pathname: nextPathname, search: nextSearch } = this.props;
if (pathname !== nextPathname || search !== nextSearch) {
trackPageView(nextPathname, nextSearch);
}
Expand Down
5 changes: 2 additions & 3 deletions packages/jaeger-ui/src/components/DeepDependencies/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,8 @@ export class DeepDependencyGraphPageImpl extends React.PureComponent<TProps, TSt
}
}

// eslint-disable-next-line camelcase
UNSAFE_componentWillReceiveProps(nextProps: TProps) {
DeepDependencyGraphPageImpl.fetchModelIfStale(nextProps);
componentDidUpdate() {
DeepDependencyGraphPageImpl.fetchModelIfStale(this.props);
}

clearOperation = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,9 @@ export default class TimelineViewingLayer extends React.PureComponent<TimelineVi
this._root = undefined;
}

// eslint-disable-next-line camelcase
UNSAFE_componentWillReceiveProps(nextProps: TimelineViewingLayerProps) {
componentDidUpdate(prevProps: Readonly<TimelineViewingLayerProps>) {
const { boundsInvalidator } = this.props;
if (boundsInvalidator !== nextProps.boundsInvalidator) {
if (prevProps.boundsInvalidator !== boundsInvalidator) {
this._draggerReframe.resetBounds();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,24 +179,29 @@ export class VirtualizedTraceViewImpl extends React.Component<VirtualizedTraceVi
return false;
}

// eslint-disable-next-line camelcase
UNSAFE_componentWillUpdate(nextProps: VirtualizedTraceViewProps) {
const { childrenHiddenIDs, detailStates, registerAccessors, trace, currentViewRangeTime } = this.props;
componentDidUpdate(prevProps: Readonly<VirtualizedTraceViewProps>) {
const { childrenHiddenIDs, detailStates, registerAccessors, trace, currentViewRangeTime } = prevProps;
const {
shouldScrollToFirstUiFindMatch,
clearShouldScrollToFirstUiFindMatch,
scrollToFirstVisibleSpan,
currentViewRangeTime: nextViewRangeTime,
childrenHiddenIDs: nextHiddenIDs,
detailStates: nextDetailStates,
registerAccessors: nextRegisterAccessors,
setTrace,
trace: nextTrace,
uiFind,
} = nextProps;
} = this.props;

if (trace !== nextTrace) {
setTrace(nextTrace, uiFind);
}

if (trace !== nextTrace || childrenHiddenIDs !== nextHiddenIDs || detailStates !== nextDetailStates) {
this.rowStates = nextTrace ? generateRowStates(nextTrace.spans, nextHiddenIDs, nextDetailStates) : [];
}

if (currentViewRangeTime !== nextViewRangeTime) {
this.clippingCssClasses = getCssClasses(nextViewRangeTime);
const [zoomStart, zoomEnd] = nextViewRangeTime;
Expand All @@ -207,17 +212,11 @@ export class VirtualizedTraceViewImpl extends React.Component<VirtualizedTraceVi
viewEnd: zoomEnd,
});
}

if (this.listView && registerAccessors !== nextRegisterAccessors) {
nextRegisterAccessors(this.getAccessors());
}
}

componentDidUpdate() {
const {
shouldScrollToFirstUiFindMatch,
clearShouldScrollToFirstUiFindMatch,
scrollToFirstVisibleSpan,
} = this.props;
if (shouldScrollToFirstUiFindMatch) {
scrollToFirstVisibleSpan();
clearShouldScrollToFirstUiFindMatch();
Expand Down
9 changes: 3 additions & 6 deletions packages/jaeger-ui/src/components/TracePage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,11 @@ export class TracePageImpl extends React.PureComponent<TProps, TState> {
mergeShortcuts(shortcutCallbacks);
}

// eslint-disable-next-line camelcase
UNSAFE_componentWillReceiveProps(nextProps: TProps) {
const { trace } = nextProps;
this._scrollManager.setTrace(trace && trace.data);
}

componentDidUpdate({ id: prevID }: TProps) {
const { id, trace } = this.props;

this._scrollManager.setTrace(trace && trace.data);

this.setHeaderHeight(this._headerElm);
if (!trace) {
this.ensureTraceFetched();
Expand Down