Skip to content

Instantly share code, notes, and snippets.

export default {
getInitialState() {
const data = {};
this.subscribe(this.props, this.context, (key, value) => {
data[key] = value;
});
this.unsubscribe();
return { data };
@markdalgleish
markdalgleish / MyComponent.js
Created September 11, 2015 05:39
CSS Modules + ReactCSSTransitionGroup in React 0.14
import transitions from './transitions.css';
export default () => (
<ReactCSSTransitionGroup transitionName={transitions}>
{ ... }
</ReactCSSTransitionGroup>
);
@rjchatfield
rjchatfield / transducers.swift
Last active January 13, 2019 13:41
Transducers & Reducers in Swift 2
//-- This is an introduction to Transducers in Swift, inspired by
// Talk: https://www.youtube.com/watch?v=estNbh2TF3E
// Code: https://github.com/mbrandonw/learn-transducers-playground
// Updated with Swift 2
/**
* Define a few test methods
*/
/// REDUCER
func append <A> (xs: [A], x: A) -> [A] { return xs + [x] }
@samwgoldman
samwgoldman / example.js
Last active April 3, 2021 22:20
Pure, stateless, type-checked React components with Immutable.js and Flow
/* @flow */
var React = require("react")
var Immutable = require("immutable")
// In order to use any type as props, including Immutable objects, we
// wrap our prop type as the sole "data" key passed as props.
type Component<P> = ReactClass<{},{ data: P },{}>
type Element = ReactElement<any, any, any>
@fabiogiolito
fabiogiolito / FacebookReactions.swift
Last active August 11, 2022 15:25
Recreating Facebook Reactions with SwiftUI. Demo Video: https://twitter.com/fabiogiolito/status/1142226669471748096
//
// FacebookReactions.swift
//
// Created by Fabio Giolito on 10/06/2019.
// Follow me: https://twitter.com/fabiogiolito
//
import SwiftUI
struct FacebookReactions : View {
@mikermcneil
mikermcneil / using-raw-socket-io-in-sails.js
Created September 17, 2013 18:32
Using raw socket.io functionality in a Sails.js controller
module.exports = {
/**
*
* Using raw socket.io functionality from a Sails.js controller
*
*/
index: function (req,res) {
@robertjpayne
robertjpayne / RCTSwiftBridgeModule.h
Last active January 17, 2024 11:43
React Native - Swift Native Modules
#import <Foundation/Foundation.h>
#import "RCTBridgeModule.h"
#define RCT_EXTERN_MODULE(objc_name, objc_supername) \
RCT_EXTERN_REMAP_MODULE(objc_name, objc_name, objc_supername)
#define RCT_EXTERN_REMAP_MODULE(js_name, objc_name, objc_supername) \
objc_name : objc_supername \
@end \
@interface objc_name (RCTExternModule) <RCTBridgeModule> \