Skip to content

Instantly share code, notes, and snippets.

View gaperton's full-sized avatar

Vlad Balin gaperton

View GitHub Profile
@define class UserForm extends React.Component {
static state = {
name : '',
email : '',
isActive : true
}
onSubmit = () => { /* TBD */ };
onCancel = () => { /* TBD */ };
@gaperton
gaperton / models.js
Last active March 8, 2018 23:19
mobx serializer example with Type-R
import { define, Record } from 'type-r';
@define
export class Box extends Record {
static attributes = {
x : Number,
y : Number,
location : String
}
@gaperton
gaperton / afterRender.js
Last active December 2, 2018 03:20
afterRender( hook )
const AfterRenderMixin = {
componentDidMount : callAfterRenderHooks,
componentDidUpdate : callAfterRenderHooks,
afterRender( hook ){
const { _callAfterRender } = this;
this._callafterRender = _callAfterRender ? () => {
_callAfterRender();
hook();
} : hook;
@gaperton
gaperton / basic.js
Last active April 23, 2019 21:41
Reach Hooks into NestedLink
import React from 'react';
import { useLink } from 'valuelink'
function Example() {
const counter = useLink(0);
return (
<div>
<p>You clicked {counter.value} times</p>
<button onClick={counter.action( x => x + 1 )}>