fix: use JavaScript default parameters instead React's defaultProps (#9453)

This commit is contained in:
Joon Kyoung
2024-01-04 22:32:21 +09:00
committed by GitHub
parent f7bd96f453
commit d5a51463ff
16 changed files with 15 additions and 95 deletions

View File

@@ -7,7 +7,7 @@ import classNames from "classnames"
import { useComponent } from "../../hooks"
const Accordion = ({ expanded, children, onChange }) => {
const Accordion = ({ expanded = false, children, onChange }) => {
const ChevronRightIcon = useComponent("ChevronRightIcon")
const handleExpansion = useCallback(
@@ -42,8 +42,4 @@ Accordion.propTypes = {
onChange: PropTypes.func.isRequired,
}
Accordion.defaultProps = {
expanded: false,
}
export default Accordion

View File

@@ -23,7 +23,7 @@ import {
} from "../../context"
const JSONSchema = forwardRef(
({ schema, name, dependentRequired, onExpand }, ref) => {
({ schema, name = "", dependentRequired = [], onExpand = () => {} }, ref) => {
const fn = useFn()
const isExpanded = useIsExpanded()
const isExpandedDeeply = useIsExpandedDeeply()
@@ -215,10 +215,4 @@ JSONSchema.propTypes = {
onExpand: PropTypes.func,
}
JSONSchema.defaultProps = {
name: "",
dependentRequired: [],
onExpand: () => {},
}
export default JSONSchema

View File

@@ -7,7 +7,7 @@ import PropTypes from "prop-types"
import { schema } from "../../../prop-types"
import { useFn } from "../../../hooks"
const Title = ({ title, schema }) => {
const Title = ({ title = "", schema }) => {
const fn = useFn()
const renderedTitle = title || fn.getTitle(schema)
@@ -25,8 +25,4 @@ Title.propTypes = {
schema: schema.isRequired,
}
Title.defaultProps = {
title: "",
}
export default Title

View File

@@ -7,7 +7,7 @@ import PropTypes from "prop-types"
import { schema } from "../../prop-types"
import { useFn } from "../../hooks"
const Type = ({ schema, isCircular }) => {
const Type = ({ schema, isCircular = false }) => {
const fn = useFn()
const type = fn.getType(schema)
const circularSuffix = isCircular ? " [circular]" : ""
@@ -24,8 +24,4 @@ Type.propTypes = {
isCircular: PropTypes.bool,
}
Type.defaultProps = {
isCircular: false,
}
export default Type