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

@@ -84,7 +84,7 @@ const ThrownErrorItem = ( { error, jumpToLine } ) => {
)
}
const SpecErrorItem = ( { error, jumpToLine } ) => {
const SpecErrorItem = ( { error, jumpToLine = null } ) => {
let locationMessage = null
if(error.get("path")) {
@@ -126,10 +126,6 @@ ThrownErrorItem.propTypes = {
jumpToLine: PropTypes.func
}
ThrownErrorItem.defaultProps = {
jumpToLine: null
}
SpecErrorItem.propTypes = {
error: PropTypes.object.isRequired,
jumpToLine: PropTypes.func

View File

@@ -7,7 +7,7 @@ import isFunction from "lodash/isFunction"
import saveAs from "js-file-download"
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 canSyntaxHighlight = get(config, "syntaxHighlight") !== false && get(config, "syntaxHighlight.activated", true)
const rootRef = useRef(null)
@@ -82,8 +82,4 @@ HighlightCode.propTypes = {
canCopy: PropTypes.bool
}
HighlightCode.defaultProps = {
fileName: "response.txt"
}
export default HighlightCode

View File

@@ -18,7 +18,7 @@ if (DomPurify.addHook) {
})
}
function Markdown({ source, className = "", getConfigs }) {
function Markdown({ source, className = "", getConfigs = () => ({ useUnsafeMarkdown: false }) }) {
if (typeof source !== "string") {
return null
}
@@ -51,10 +51,6 @@ Markdown.propTypes = {
getConfigs: PropTypes.func,
}
Markdown.defaultProps = {
getConfigs: () => ({ useUnsafeMarkdown: false }),
}
export default Markdown
export function sanitizer(str, { useUnsafeMarkdown = false } = {}) {