Skip to content

Instantly share code, notes, and snippets.

@corlaez
Created September 27, 2019 23:42
Show Gist options
  • Save corlaez/41cb604f598d01ad665dd6164853b662 to your computer and use it in GitHub Desktop.
Save corlaez/41cb604f598d01ad665dd6164853b662 to your computer and use it in GitHub Desktop.
Hooks predecesors
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>
);
}
});
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