Last active
April 27, 2016 10:22
-
-
Save erikras/60504cbdcdf5ab29235371d990f43244 to your computer and use it in GitHub Desktop.
The HOC Drill Pattern [BEFORE]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react' | |
import MyWrappedComponent from './MyWrappedComponent' | |
export default class MyContainer extends Component { | |
constructor() { | |
// bind handlers | |
this.handleLoad = this.handleLoad.bind(this) | |
this.handleSave = this.handleSave.bind(this) | |
this.handleClear = this.handleClear.bind(this) | |
} | |
handleLoad() { | |
// somehow call load() on MyWrappedComponent | |
} | |
handleSave() { | |
// somehow call save() on MyWrappedComponent | |
} | |
handleClear() { | |
// somehow call clear() on MyWrappedComponent | |
} | |
render() { | |
return ( | |
<div> | |
<button onClick={this.handleLoad}>Load</button> | |
<button onClick={this.handleSave}>Save</button> | |
<button onClick={this.handleClear}>Clear</button> | |
<MyWrappedComponent/> | |
</div> | |
) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react' | |
import { hocLibrary } from 'some-hoc-library' | |
@hocLibrary({ config: 'parameters' }) | |
export default class MyWrappedComponent extends Component { | |
load() { | |
// load something | |
} | |
save() { | |
// save something | |
} | |
clear() { | |
// clear something | |
} | |
render() { | |
return <div>Gorgeous UI</div> | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment