init
This commit is contained in:
39
src/pages/HocPage.js
Normal file
39
src/pages/HocPage.js
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
/**
|
||||||
|
* 高阶组件
|
||||||
|
*/
|
||||||
|
import React, {Component} from 'react';
|
||||||
|
// function Child(props) {
|
||||||
|
// return <div>Child</div>
|
||||||
|
// }
|
||||||
|
|
||||||
|
const foo = Cmp => props => {
|
||||||
|
return (
|
||||||
|
<div className="border">
|
||||||
|
<Cmp {...props}/>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
};
|
||||||
|
// const Foo=foo(Child);
|
||||||
|
class HocPage extends Component {
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h1>HocPage</h1>
|
||||||
|
<Child></Child>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@foo
|
||||||
|
class Child extends Component {
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<p>Child</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default HocPage;
|
Reference in New Issue
Block a user