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
|
||||
|
||||
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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 } = {}) {
|
||||
|
||||
Reference in New Issue
Block a user