Skip to content

Commit

Permalink
[TraceHeader]: Replace defaultProps with destructuring
Browse files Browse the repository at this point in the history
Partially Resolves jaegertracing#2596
- Remove defaultProps from the component, replace with destructuring

Signed-off-by: Abhishek <[email protected]>
  • Loading branch information
its-me-abhishek committed Jan 24, 2025
1 parent 2d880b4 commit 49443a3
Showing 1 changed file with 26 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,6 @@ import { ApiError } from '../../../types/api-error';

import './TraceHeader.css';

type Props = {
duration: number | TNil;
error?: ApiError;
startTime: number | TNil;
state: FetchedState | TNil;
traceID: string | TNil;
traceName: string | TNil;
totalSpans: number | TNil;
};

type AttrsProps = {
startTime: number | TNil;
duration: number | TNil;
totalSpans: number | TNil;
};

// exported for tests
export function EmptyAttrs() {
return (
Expand All @@ -54,8 +38,15 @@ export function EmptyAttrs() {
}

// exported for tests
export function Attrs(props: AttrsProps) {
const { startTime, duration, totalSpans } = props;
export function Attrs({
startTime,
duration,
totalSpans,
}: {
startTime: number | TNil;
duration: number | TNil;
totalSpans: number | TNil;
}) {
return (
<ul className="TraceDiffHeader--traceAttributes" data-testid="TraceDiffHeader--traceAttributes">
<li className="TraceDiffHeader--traceAttr" data-testid="TraceDiffHeader--traceAttr">
Expand All @@ -75,8 +66,23 @@ export function Attrs(props: AttrsProps) {
);
}

export default function TraceHeader(props: Props) {
const { duration, error, startTime, state, traceID, totalSpans, traceName } = props;
export default function TraceHeader({
duration,
error = undefined,
startTime,
state,
traceID,
totalSpans,
traceName,
}: {
duration: number | TNil;
error?: ApiError;
startTime: number | TNil;
state: FetchedState | TNil;
traceID: string | TNil;
traceName: string | TNil;
totalSpans: number | TNil;
}) {
const AttrsComponent = state === fetchedState.DONE ? Attrs : EmptyAttrs;

return (
Expand All @@ -101,7 +107,3 @@ export default function TraceHeader(props: Props) {
</div>
);
}

TraceHeader.defaultProps = {
error: undefined,
};

0 comments on commit 49443a3

Please sign in to comment.