fix: use JavaScript default parameters instead React's defaultProps (#9453)
This commit is contained in:
@@ -84,7 +84,7 @@ const ThrownErrorItem = ( { error, jumpToLine } ) => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const SpecErrorItem = ( { error, jumpToLine } ) => {
|
const SpecErrorItem = ( { error, jumpToLine = null } ) => {
|
||||||
let locationMessage = null
|
let locationMessage = null
|
||||||
|
|
||||||
if(error.get("path")) {
|
if(error.get("path")) {
|
||||||
@@ -126,10 +126,6 @@ ThrownErrorItem.propTypes = {
|
|||||||
jumpToLine: PropTypes.func
|
jumpToLine: PropTypes.func
|
||||||
}
|
}
|
||||||
|
|
||||||
ThrownErrorItem.defaultProps = {
|
|
||||||
jumpToLine: null
|
|
||||||
}
|
|
||||||
|
|
||||||
SpecErrorItem.propTypes = {
|
SpecErrorItem.propTypes = {
|
||||||
error: PropTypes.object.isRequired,
|
error: PropTypes.object.isRequired,
|
||||||
jumpToLine: PropTypes.func
|
jumpToLine: PropTypes.func
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import isFunction from "lodash/isFunction"
|
|||||||
import saveAs from "js-file-download"
|
import saveAs from "js-file-download"
|
||||||
import { CopyToClipboard } from "react-copy-to-clipboard"
|
import { CopyToClipboard } from "react-copy-to-clipboard"
|
||||||
|
|
||||||
const HighlightCode = ({value, fileName, className, downloadable, getConfigs, canCopy, language}) => {
|
const HighlightCode = ({value, fileName = "response.txt", className, downloadable, getConfigs, canCopy, language}) => {
|
||||||
const config = isFunction(getConfigs) ? getConfigs() : null
|
const config = isFunction(getConfigs) ? getConfigs() : null
|
||||||
const canSyntaxHighlight = get(config, "syntaxHighlight") !== false && get(config, "syntaxHighlight.activated", true)
|
const canSyntaxHighlight = get(config, "syntaxHighlight") !== false && get(config, "syntaxHighlight.activated", true)
|
||||||
const rootRef = useRef(null)
|
const rootRef = useRef(null)
|
||||||
@@ -82,8 +82,4 @@ HighlightCode.propTypes = {
|
|||||||
canCopy: PropTypes.bool
|
canCopy: PropTypes.bool
|
||||||
}
|
}
|
||||||
|
|
||||||
HighlightCode.defaultProps = {
|
|
||||||
fileName: "response.txt"
|
|
||||||
}
|
|
||||||
|
|
||||||
export default HighlightCode
|
export default HighlightCode
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ if (DomPurify.addHook) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function Markdown({ source, className = "", getConfigs }) {
|
function Markdown({ source, className = "", getConfigs = () => ({ useUnsafeMarkdown: false }) }) {
|
||||||
if (typeof source !== "string") {
|
if (typeof source !== "string") {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
@@ -51,10 +51,6 @@ Markdown.propTypes = {
|
|||||||
getConfigs: PropTypes.func,
|
getConfigs: PropTypes.func,
|
||||||
}
|
}
|
||||||
|
|
||||||
Markdown.defaultProps = {
|
|
||||||
getConfigs: () => ({ useUnsafeMarkdown: false }),
|
|
||||||
}
|
|
||||||
|
|
||||||
export default Markdown
|
export default Markdown
|
||||||
|
|
||||||
export function sanitizer(str, { useUnsafeMarkdown = false } = {}) {
|
export function sanitizer(str, { useUnsafeMarkdown = false } = {}) {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
import React from "react"
|
import React from "react"
|
||||||
import PropTypes from "prop-types"
|
import PropTypes from "prop-types"
|
||||||
|
|
||||||
const ArrowDown = ({ className, width, height, ...rest }) => (
|
const ArrowDown = ({ className = null, width = 20, height = 20, ...rest }) => (
|
||||||
<svg
|
<svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
viewBox="0 0 20 20"
|
viewBox="0 0 20 20"
|
||||||
@@ -25,10 +25,4 @@ ArrowDown.propTypes = {
|
|||||||
height: PropTypes.string,
|
height: PropTypes.string,
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrowDown.defaultProps = {
|
|
||||||
className: null,
|
|
||||||
width: 20,
|
|
||||||
height: 20,
|
|
||||||
}
|
|
||||||
|
|
||||||
export default ArrowDown
|
export default ArrowDown
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
import React from "react"
|
import React from "react"
|
||||||
import PropTypes from "prop-types"
|
import PropTypes from "prop-types"
|
||||||
|
|
||||||
const ArrowUp = ({ className, width, height, ...rest }) => (
|
const ArrowUp = ({ className = null, width = 20, height = 20, ...rest }) => (
|
||||||
<svg
|
<svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
viewBox="0 0 20 20"
|
viewBox="0 0 20 20"
|
||||||
@@ -25,10 +25,4 @@ ArrowUp.propTypes = {
|
|||||||
height: PropTypes.string,
|
height: PropTypes.string,
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrowUp.defaultProps = {
|
|
||||||
className: null,
|
|
||||||
width: 20,
|
|
||||||
height: 20,
|
|
||||||
}
|
|
||||||
|
|
||||||
export default ArrowUp
|
export default ArrowUp
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
import React from "react"
|
import React from "react"
|
||||||
import PropTypes from "prop-types"
|
import PropTypes from "prop-types"
|
||||||
|
|
||||||
const Arrow = ({ className, width, height, ...rest }) => (
|
const Arrow = ({ className = null, width = 20, height = 20, ...rest }) => (
|
||||||
<svg
|
<svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
viewBox="0 0 20 20"
|
viewBox="0 0 20 20"
|
||||||
@@ -25,10 +25,4 @@ Arrow.propTypes = {
|
|||||||
height: PropTypes.string,
|
height: PropTypes.string,
|
||||||
}
|
}
|
||||||
|
|
||||||
Arrow.defaultProps = {
|
|
||||||
className: null,
|
|
||||||
width: 20,
|
|
||||||
height: 20,
|
|
||||||
}
|
|
||||||
|
|
||||||
export default Arrow
|
export default Arrow
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
import React from "react"
|
import React from "react"
|
||||||
import PropTypes from "prop-types"
|
import PropTypes from "prop-types"
|
||||||
|
|
||||||
const Close = ({ className, width, height, ...rest }) => (
|
const Close = ({ className = null, width = 20, height = 20, ...rest }) => (
|
||||||
<svg
|
<svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
viewBox="0 0 20 20"
|
viewBox="0 0 20 20"
|
||||||
@@ -25,10 +25,4 @@ Close.propTypes = {
|
|||||||
height: PropTypes.string,
|
height: PropTypes.string,
|
||||||
}
|
}
|
||||||
|
|
||||||
Close.defaultProps = {
|
|
||||||
className: null,
|
|
||||||
width: 20,
|
|
||||||
height: 20,
|
|
||||||
}
|
|
||||||
|
|
||||||
export default Close
|
export default Close
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
import React from "react"
|
import React from "react"
|
||||||
import PropTypes from "prop-types"
|
import PropTypes from "prop-types"
|
||||||
|
|
||||||
const Copy = ({ className, width, height, ...rest }) => (
|
const Copy = ({ className = null, width = 15, height = 16, ...rest }) => (
|
||||||
<svg
|
<svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
viewBox="0 0 15 16"
|
viewBox="0 0 15 16"
|
||||||
@@ -31,10 +31,4 @@ Copy.propTypes = {
|
|||||||
height: PropTypes.string,
|
height: PropTypes.string,
|
||||||
}
|
}
|
||||||
|
|
||||||
Copy.defaultProps = {
|
|
||||||
className: null,
|
|
||||||
width: 15,
|
|
||||||
height: 16,
|
|
||||||
}
|
|
||||||
|
|
||||||
export default Copy
|
export default Copy
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
import React from "react"
|
import React from "react"
|
||||||
import PropTypes from "prop-types"
|
import PropTypes from "prop-types"
|
||||||
|
|
||||||
const Lock = ({ className, width, height, ...rest }) => (
|
const Lock = ({ className = null, width = 20, height = 20, ...rest }) => (
|
||||||
<svg
|
<svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
viewBox="0 0 20 20"
|
viewBox="0 0 20 20"
|
||||||
@@ -25,10 +25,4 @@ Lock.propTypes = {
|
|||||||
height: PropTypes.string,
|
height: PropTypes.string,
|
||||||
}
|
}
|
||||||
|
|
||||||
Lock.defaultProps = {
|
|
||||||
className: null,
|
|
||||||
width: 20,
|
|
||||||
height: 20,
|
|
||||||
}
|
|
||||||
|
|
||||||
export default Lock
|
export default Lock
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
import React from "react"
|
import React from "react"
|
||||||
import PropTypes from "prop-types"
|
import PropTypes from "prop-types"
|
||||||
|
|
||||||
const Unlock = ({ className, width, height, ...rest }) => (
|
const Unlock = ({ className = null, width = 20, height = 20, ...rest }) => (
|
||||||
<svg
|
<svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
viewBox="0 0 20 20"
|
viewBox="0 0 20 20"
|
||||||
@@ -25,10 +25,4 @@ Unlock.propTypes = {
|
|||||||
height: PropTypes.string,
|
height: PropTypes.string,
|
||||||
}
|
}
|
||||||
|
|
||||||
Unlock.defaultProps = {
|
|
||||||
className: null,
|
|
||||||
width: 20,
|
|
||||||
height: 20,
|
|
||||||
}
|
|
||||||
|
|
||||||
export default Unlock
|
export default Unlock
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import classNames from "classnames"
|
|||||||
|
|
||||||
import { useComponent } from "../../hooks"
|
import { useComponent } from "../../hooks"
|
||||||
|
|
||||||
const Accordion = ({ expanded, children, onChange }) => {
|
const Accordion = ({ expanded = false, children, onChange }) => {
|
||||||
const ChevronRightIcon = useComponent("ChevronRightIcon")
|
const ChevronRightIcon = useComponent("ChevronRightIcon")
|
||||||
|
|
||||||
const handleExpansion = useCallback(
|
const handleExpansion = useCallback(
|
||||||
@@ -42,8 +42,4 @@ Accordion.propTypes = {
|
|||||||
onChange: PropTypes.func.isRequired,
|
onChange: PropTypes.func.isRequired,
|
||||||
}
|
}
|
||||||
|
|
||||||
Accordion.defaultProps = {
|
|
||||||
expanded: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
export default Accordion
|
export default Accordion
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import {
|
|||||||
} from "../../context"
|
} from "../../context"
|
||||||
|
|
||||||
const JSONSchema = forwardRef(
|
const JSONSchema = forwardRef(
|
||||||
({ schema, name, dependentRequired, onExpand }, ref) => {
|
({ schema, name = "", dependentRequired = [], onExpand = () => {} }, ref) => {
|
||||||
const fn = useFn()
|
const fn = useFn()
|
||||||
const isExpanded = useIsExpanded()
|
const isExpanded = useIsExpanded()
|
||||||
const isExpandedDeeply = useIsExpandedDeeply()
|
const isExpandedDeeply = useIsExpandedDeeply()
|
||||||
@@ -215,10 +215,4 @@ JSONSchema.propTypes = {
|
|||||||
onExpand: PropTypes.func,
|
onExpand: PropTypes.func,
|
||||||
}
|
}
|
||||||
|
|
||||||
JSONSchema.defaultProps = {
|
|
||||||
name: "",
|
|
||||||
dependentRequired: [],
|
|
||||||
onExpand: () => {},
|
|
||||||
}
|
|
||||||
|
|
||||||
export default JSONSchema
|
export default JSONSchema
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import PropTypes from "prop-types"
|
|||||||
import { schema } from "../../../prop-types"
|
import { schema } from "../../../prop-types"
|
||||||
import { useFn } from "../../../hooks"
|
import { useFn } from "../../../hooks"
|
||||||
|
|
||||||
const Title = ({ title, schema }) => {
|
const Title = ({ title = "", schema }) => {
|
||||||
const fn = useFn()
|
const fn = useFn()
|
||||||
const renderedTitle = title || fn.getTitle(schema)
|
const renderedTitle = title || fn.getTitle(schema)
|
||||||
|
|
||||||
@@ -25,8 +25,4 @@ Title.propTypes = {
|
|||||||
schema: schema.isRequired,
|
schema: schema.isRequired,
|
||||||
}
|
}
|
||||||
|
|
||||||
Title.defaultProps = {
|
|
||||||
title: "",
|
|
||||||
}
|
|
||||||
|
|
||||||
export default Title
|
export default Title
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import PropTypes from "prop-types"
|
|||||||
import { schema } from "../../prop-types"
|
import { schema } from "../../prop-types"
|
||||||
import { useFn } from "../../hooks"
|
import { useFn } from "../../hooks"
|
||||||
|
|
||||||
const Type = ({ schema, isCircular }) => {
|
const Type = ({ schema, isCircular = false }) => {
|
||||||
const fn = useFn()
|
const fn = useFn()
|
||||||
const type = fn.getType(schema)
|
const type = fn.getType(schema)
|
||||||
const circularSuffix = isCircular ? " [circular]" : ""
|
const circularSuffix = isCircular ? " [circular]" : ""
|
||||||
@@ -24,8 +24,4 @@ Type.propTypes = {
|
|||||||
isCircular: PropTypes.bool,
|
isCircular: PropTypes.bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
Type.defaultProps = {
|
|
||||||
isCircular: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
export default Type
|
export default Type
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ const parser = new Remarkable("commonmark")
|
|||||||
parser.block.ruler.enable(["table"])
|
parser.block.ruler.enable(["table"])
|
||||||
parser.set({ linkTarget: "_blank" })
|
parser.set({ linkTarget: "_blank" })
|
||||||
|
|
||||||
export const Markdown = ({ source, className = "", getConfigs }) => {
|
export const Markdown = ({ source, className = "", getConfigs = () => ({ useUnsafeMarkdown: false }) }) => {
|
||||||
if(typeof source !== "string") {
|
if(typeof source !== "string") {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
@@ -42,8 +42,4 @@ Markdown.propTypes = {
|
|||||||
getConfigs: PropTypes.func,
|
getConfigs: PropTypes.func,
|
||||||
}
|
}
|
||||||
|
|
||||||
Markdown.defaultProps = {
|
|
||||||
getConfigs: () => ({ useUnsafeMarkdown: false }),
|
|
||||||
}
|
|
||||||
|
|
||||||
export default OAS3ComponentWrapFactory(Markdown)
|
export default OAS3ComponentWrapFactory(Markdown)
|
||||||
|
|||||||
@@ -29,8 +29,4 @@ DiscriminatorMapping.propTypes = {
|
|||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
|
|
||||||
DiscriminatorMapping.defaultProps = {
|
|
||||||
mapping: undefined,
|
|
||||||
}
|
|
||||||
|
|
||||||
export default DiscriminatorMapping
|
export default DiscriminatorMapping
|
||||||
|
|||||||
Reference in New Issue
Block a user