Skip to content

Instantly share code, notes, and snippets.

View sgwilym's full-sized avatar
🌳
Working on Willow

Sam Gwilym sgwilym

🌳
Working on Willow
View GitHub Profile
@sgwilym
sgwilym / schema.graphql
Created April 26, 2019 12:26
ssb-patchql schema SDL
schema {
query: Query
mutation: DbMutation
}
type Author {
name: String
description: String
imageLink: String
id: String!
// Example of what data masking gets us with Relay
const AdminList = createFragmentContainer(
(props) => <div>
{props.admins.map((admin) => <div>{admin.name}</div>)}
</div>,
{
admins: graphql`
fragment AdminList_admins on User @relay(plural: true) {
name
@sgwilym
sgwilym / useIsMounted.js
Created February 12, 2019 17:27
useIsMounted hook
let useIsMounted = () => {
let isMountedRef = useRef(false);
useEffect(() => {
isMountedRef.current = true;
}, [])
return isMountedRef.current;
}
@sgwilym
sgwilym / Libraries-slash-Components-slashScrollView-slash-ScrollView.js
Created February 16, 2016 18:02
Manually merged react-native upstream changes for pagination in ScrollView
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule ScrollView
* @flow
import Relay from 'react-relay';
import request from 'superagent';
var savedHeaders;
try {
savedHeaders = JSON.parse(localStorage.getItem('SAVED_CREDS_KEY'));
} catch(err) {
savedHeaders = null;
};
@sgwilym
sgwilym / gist:52640d38f17313e5bada
Last active August 29, 2015 14:19
Embedded flux entity class in Store with custom getters for associations
import { Store } from 'flummox';
import React from 'react/addons';
export default class UserStore extends Store {
constructor(flux) {
super();
this.registerAll(this.addUsers);