【发布时间】:2020-08-23 12:24:27
【问题描述】:
我在网上找到了这段代码,但是,我是 React 的初学者,我看不懂。这段代码有什么作用?它会克隆组件吗?
对于这个非常基本的问题,我感到非常抱歉。非常感谢您的帮助!
const Factory = function ({
React,
thing,
isActive,
addThing,
deleteThing,
name,
description,
} = {}) {
const Thing = function (props) {
return {
propTypes: {
thing: React.PropTypes.object,
isActive: React.PropTypes.bool,
addThing: React.PropTypes.func,
deleteThing: React.PropTypes.func,
name: React.PropType.string,
description: React.PropType.string,
},
props,
render () {
return (
<Card>
<Card.Body>
<Card.Title>{ this.props.name }</Card.Title>
<Card.Text>{ this.props.description }</Card.Text>
</Card.Body>
</Card>
);
}
};
};
return Thing;
};
export default Factory;
【问题讨论】:
-
你能分享这篇文章的链接吗