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

Remove default props #2597

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ node_modules

# production
build

# reports
coverage
.nyc_output
Expand Down
31 changes: 2 additions & 29 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -262,12 +262,12 @@ export class SearchFormImpl extends React.PureComponent {
render() {
const {
handleSubmit,
invalid,
invalid = false,
searchMaxLookback,
selectedLookback,
selectedService = '-',
services,
submitting: disabled,
selectedLookback = null,
selectedService = null,
services = [],
submitting = false,
} = this.props;
const selectedServicePayload = services.find(s => s.name === selectedService);
const opsForSvc = (selectedServicePayload && selectedServicePayload.operations) || [];
Expand Down Expand Up @@ -555,14 +555,6 @@ SearchFormImpl.propTypes = {
selectedLookback: PropTypes.string,
};

SearchFormImpl.defaultProps = {
invalid: false,
services: [],
submitting: false,
selectedService: null,
selectedLookback: null,
};

export const searchSideBarFormSelector = formValueSelector('searchSideBar');

export function mapStateToProps(state) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ import { ONE_MILLISECOND, formatDuration } from '../../../utils/date';
import 'react-vis/dist/style.css';
import './ScatterPlot.css';

export default function ScatterPlot(props) {
const { data, onValueClick, calculateContainerWidth } = props;

export default function ScatterPlot({
data,
onValueClick,
calculateContainerWidth = container => container.clientWidth,
}) {
const containerRef = useRef(null);
const [containerWidth, setContainerWidth] = useState(0);

Expand Down Expand Up @@ -103,8 +105,3 @@ ScatterPlot.propTypes = {
onValueClick: PropTypes.func.isRequired,
calculateContainerWidth: PropTypes.func,
};

ScatterPlot.defaultProps = {
// JSDOM does not, as of 2023, have a layout engine, so allow tests to supply a mock width as a workaround.
calculateContainerWidth: container => container.clientWidth,
};
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,15 @@ 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,
}: Props) {
const AttrsComponent = state === fetchedState.DONE ? Attrs : EmptyAttrs;

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

TraceHeader.defaultProps = {
error: undefined,
};
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ type AccordianKeyValuesProps = {
};

// export for tests
export function KeyValuesSummary(props: { data?: KeyValuePair[] }) {
const { data } = props;
export function KeyValuesSummary({ data = null }: { data?: KeyValuePair[] | null }) {
if (!Array.isArray(data) || !data.length) {
return null;
}
Expand All @@ -55,12 +54,16 @@ export function KeyValuesSummary(props: { data?: KeyValuePair[] }) {
);
}

KeyValuesSummary.defaultProps = {
data: null,
};

export default function AccordianKeyValues(props: AccordianKeyValuesProps) {
const { className, data, highContrast, interactive, isOpen, label, linksGetter, onToggle } = props;
export default function AccordianKeyValues({
className = null,
data,
highContrast = false,
interactive = true,
isOpen,
label,
linksGetter,
onToggle = null,
}: AccordianKeyValuesProps) {
const isEmpty = !Array.isArray(data) || !data.length;
const iconCls = cx('u-align-icon', { 'AccordianKeyValues--emptyIcon': isEmpty });
let arrow: React.ReactNode | null = null;
Expand Down Expand Up @@ -94,10 +97,3 @@ export default function AccordianKeyValues(props: AccordianKeyValuesProps) {
</div>
);
}

AccordianKeyValues.defaultProps = {
className: null,
highContrast: false,
interactive: true,
onToggle: null,
};
Loading