Reactjs PropType已定义,但prop从未用于具有单个参数的arrow函数

Reactjs PropType已定义,但prop从未用于具有单个参数的arrow函数,reactjs,Reactjs,假设我有这样的代码 const MessageBody = inner => ( // eslint-disable-next-line react/no-danger <div dangerouslySetInnerHTML={{ __html: inner }} /> ); MessageBody.propTypes = { /** * Message itself, this can be a html element or plain string

假设我有这样的代码

const MessageBody = inner => (
  // eslint-disable-next-line react/no-danger
  <div dangerouslySetInnerHTML={{ __html: inner }} />
);

MessageBody.propTypes = {
  /**
   * Message itself, this can be a html element or plain string
   */
  inner: PropTypes.oneOfType([
    PropTypes.string,
    PropTypes.element,
  ]),
};
const MessageBody=internal=>(
//eslint禁用下一行反应/无危险
);
MessageBody.propTypes={
/**
*消息本身,可以是html元素或普通字符串
*/
内部:PropTypes.oneOfType([
PropTypes.string,
PropTypes.element,
]),
};
埃斯林特说 定义了“内部”道具类型,但道具从不使用棉绒(反应/无未使用的道具类型)


如何解决这个问题?

现在,您已经命名了您的
道具
变量
internal
,而不是检索它,因此道具上的
internal
从未使用过。需要做的是用以下方法从道具中解构
内部

const MessageBody = ({ inner }) => (
....
或者,您可以修复道具的名称,并使用以下工具从中获取内部信息:

const MessageBody = props => (
  // eslint-disable-next-line react/no-danger
  <div dangerouslySetInnerHTML={{ __html: props.inner }} />
);
const MessageBody=props=>(
//eslint禁用下一行反应/无危险
);