Created
September 27, 2019 23:42
-
-
Save corlaez/41cb604f598d01ad665dd6164853b662 to your computer and use it in GitHub Desktop.
Hooks predecesors
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 from "react"; | |
var MyMixin = { | |
componentDidUpdate() { | |
this.componentMethod() | |
}, | |
mixinMethod() {} | |
}; | |
const MyComponent = React.createClass({ | |
// Implicitly implements componentDidUpdate and | |
// requires this component to implement componentMethod | |
mixins: [MyMixin], | |
handleClick() { | |
this.mixinMethod(); // Invoke mixin's method | |
}, | |
componentMethod() {}, | |
render() { | |
return ( | |
<button onClick={this.handleClick}>Do Something</button> | |
); | |
} | |
}); |
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 from "react"; | |
import {DataFetcher, Actions, Translations, Styles} from "xyz" | |
const myForm = () => ( | |
<DataFetcher> | |
{(data) => ( | |
<Actions> | |
{(actions) => ( | |
<Translations> | |
{(translations) => ( | |
<Styles> | |
{(styles) => ( | |
<form styles={styles}> | |
<input value={data.value}/> | |
<button onClick={actions.submit}> | |
{translations.submitText} | |
</button> | |
</form> | |
)} | |
</Styles> | |
)} | |
</Translations> | |
)} | |
</Actions> | |
)} | |
</DataFetcher> | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment