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
module Apollo = ReactApollo.CreateMutationWrapper(SignInMutationGql); | |
let component = ReasonReact.statelessComponent("SignInForm"); | |
/* Convert user data to JS */ | |
let convertToJs: SignInFormParams.state => SignInMutationGql.Types.signInInput = | |
(values) => {"password": values.password, "email": values.email}; | |
let make = (_children) => { | |
...component, |
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
/* 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; | |
}; |
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
/* 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 }; |
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
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 | |
); | |
}; |
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
type hoc = ReasonReact.reactClass => ReasonReact.reactClass; | |
module Create = | |
( | |
Params: { | |
type hocParams; | |
let hoc: | |
hocParams; | |
type children; | |
let handlePropsFromJs | |
} |
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
/* 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 = { |
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
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) |
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 { compose, withStateHandlers, withHandlers } from 'recompose' | |
export default compose( | |
withStateHandlers({ | |
isFetching: false, | |
name: '', | |
data: null | |
}, { | |
setFetching: (state) => (isFetching) => ({ ...state, isFetching }), | |
setData: (state) => (data) => ({ ...state, data }), |
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
function createStore(reducer) { | |
let state = reducer(null, undefined); | |
return { | |
dispatch: action => { state = reducer(action, state) }, | |
getState: () => state, | |
} | |
} | |
const store = createStore((action, state = 0) => { |
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
<SignUpForm | |
schema=[ | |
(`password, Required), | |
(`email, Required), | |
( | |
`confirmPassword, | |
Custom( | |
values => | |
values.confirmPassword !== values.password ? | |
Some("Passwords don't match") : None, |