Skip to content

Instantly share code, notes, and snippets.

@zhaoyao91
zhaoyao91 / define_component.js
Created May 20, 2017
HOC to define a component which requires display name, prop types and being pure
View define_component.js
import { setDisplayName, setPropTypes, pure, compose } from 'recompose'
export default function (displayName, propTypes = {}) {
return compose(
setDisplayName(displayName),
setPropTypes(propTypes),
pure
)
}
View pomisify_meteor_apis.js
import { Meteor } from 'meteor/meteor'
import { Accounts } from 'meteor/accounts-base'
import { assoc, keys, isFunction, reduce } from 'lodash/fp'
export default function () {
promisifyObject(Meteor)
promisifyObject(Accounts)
}
function promisifyObject (target) {
@zhaoyao91
zhaoyao91 / with_meteor_data.js
Created May 26, 2017
provide meteor reactive data
View with_meteor_data.js
import { createContainer } from 'meteor/react-meteor-data'
import { curryN } from 'lodash/fp'
export default curryN(2)(createContainer)
@zhaoyao91
zhaoyao91 / with_dynamic_module.js
Last active Jun 19, 2017
HOC to allow a react component declare and load dynamic module(s)
View with_dynamic_module.js
import React from 'react'
import { defaults } from 'lodash/fp'
/**
* load a dynamic module
*
* e.g.
*
* case: load a single module
* withDynamicModule('SomeComponent', () => import('some-component').then(mod => mod.default))