Skip to content

Instantly share code, notes, and snippets.

View fakenickels's full-sized avatar
💭
hello this is a mic test, are you listening

Gabriel fakenickels

💭
hello this is a mic test, are you listening
View GitHub Profile
@fakenickels
fakenickels / keybase.md
Created April 30, 2018 02:26
keybase.md

Keybase proof

I hereby claim:

  • I am grsabreu on github.
  • I am gabrielrubens (https://keybase.io/gabrielrubens) on keybase.
  • I have a public key ASBmi5BWN9iQGzaes0ztgBxC2pa-n5OmVll_pPTwxAkllAo

To claim this, I am signing this object:

<SignUpForm
schema=[
(`password, Required),
(`email, Required),
(
`confirmPassword,
Custom(
values =>
values.confirmPassword !== values.password ?
Some("Passwords don't match") : None,
function createStore(reducer) {
let state = reducer(null, undefined);
return {
dispatch: action => { state = reducer(action, state) },
getState: () => state,
}
}
const store = createStore((action, state = 0) => {
import { compose, withStateHandlers, withHandlers } from 'recompose'
export default compose(
withStateHandlers({
isFetching: false,
name: '',
data: null
}, {
setFetching: (state) => (isFetching) => ({ ...state, isFetching }),
setData: (state) => (data) => ({ ...state, data }),
rm -rf foo.html && ((pbpaste | prettier --semi false --trailing-comma all --single-quote true | highlight --inline-css --syntax=js --font-size 18 --font Verdana --style zellner) > foo.html)
@fakenickels
fakenickels / ReForm.re
Created February 8, 2018 17:26
HOC-y ReForm
/* Validation types */
let safeHd = lst => List.length(lst) == 0 ? None : Some(List.hd(lst));
let (>>=) = (value, map) =>
switch value {
| None => None
| Some(value) => map(value)
};
module Validation = {
@fakenickels
fakenickels / BindHOC.re
Last active April 7, 2018 01:54
A general HOC functor
type hoc = ReasonReact.reactClass => ReasonReact.reactClass;
module Create =
(
Params: {
type hocParams;
let hoc:
hocParams;
type children;
let handlePropsFromJs
}
module MakeComponent = (Config: { let reactClass: ReasonReact.reactClass; let name: string; }) => {
let component = ReasonReact.statelessComponent(Config.name);
let make = children =>
ReasonReact.wrapJsForReason(
~reactClass=Config.reactClass,
~props={"yourProp": 123},
children
);
};
/* file: Recompose.re */
module type CreateWithStateParams = {
/* This is the secret sauce ingredient, with it the users can pass whatever state they want */
type state;
};
module CreateWithState = (Params: CreateWithStateParams) => {
type value;
type state = { value: Params.state };
/* file: Recompose.re */
/* The very definition of a HOC, it's a function that gets a react component and returns another react component */
type hoc = ReasonReact.reactClass => ReasonReact.reactClass;
module type CreateWithStateParams = {
/* This is the secret sauce ingredient, with it the users can pass whatever state they want */
type state;
let defaultValue: state;
};