- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
下面的代码示例是组件的简化版本。我不明白该组件底部的代码,即 Case.wrappedComponent.propTypes 部分。我在互联网上也找不到有关wrappedComponent的相关文档。
问题:
在哪里可以找到这些内容的文档?
import React, { Component } from 'react';
@inject('store') @observer
export default class Case extends Component {
constructor(props) {
super(props);
this.caseId = this.props.match.params.id;
this.setOtherComment = this.setOtherComment.bind(this)
this.submitOtherComment = this.submitOtherComment.bind(this)
}
render() {
return '...'
}
}
Case.wrappedComponent.propTypes = {
store: React.PropTypes.object.isRequired,
match: React.PropTypes.object.isRequired
};
最佳答案
这是 mobx-react
的 API(带注入(inject)),根据 DOCS
Using propTypes and defaultProps and other static properties in combination with inject Inject wraps a new component around the component you pass into it. This means that assigning a static property to the resulting component, will be applied to the HoC, and not to the original component
........
if you want to make assertions on the data that is being injected (either stores or data resulting from a mapper function), the propTypes should be defined on the wrapped component. Which is available through the static property wrappedComponent on the inject component
关于reactjs - 在reactjs中,wrappedComponent.propTypes是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47611926/
下面的代码示例是组件的简化版本。我不明白该组件底部的代码,即 Case.wrappedComponent.propTypes 部分。我在互联网上也找不到有关wrappedComponent的相关文档。
我正在尝试做什么: 我正在尝试使用shallow按照以下模式从 enzyme 进行渲染,该模式适用于我的项目中的许多其他组件。 describe('>> MyComponent - Render',
我正在尝试测试我的组件“CBreadcrumb”,它使用“withRouter”HOC。运行测试用例时,所有测试用例都通过,但显示警告。 我已经多次尝试检查我的代码。但我无法找到警告的原因。我也尝试过
当我进入我的 React Router-dom 时,我将我的路由指向验证页面。无论目标是否登录,我都会将我的route(history) 推送到所需的页面,但我不断收到以下错误消息。 Error: O
我是一名优秀的程序员,十分优秀!