Skip to content

Instantly share code, notes, and snippets.

View helielson's full-sized avatar

Helielson helielson

  • Indaband, Frontend Bahia
  • Salvador, Brazil
View GitHub Profile
// ScreenB
const ScreenBQuery = graphql`
query ScreenBQuery {
root {
events(first: $first) {
edges {
node {
title
}
}
case 'store-or-network': {
shouldFetch = !hasFullQuery;
shouldAllowRender = canPartialRender;
break;
}
// https://github.com/facebook/relay/blob/66e747a68b8fac474fa44b4eb441c72c72daf89e/packages/relay-experimental/QueryResource.js#L392-L395
_traverse(node: NormalizationNode, dataID: DataID): void {
const status = this._mutator.getStatus(dataID);
if (status === UNKNOWN) {
this._handleMissing();
}
if (status === EXISTENT) {
this._traverseSelections(node.selections, dataID);
}
}
// ScreenA
const ScreenAQuery = graphql`
query ScreenAQuery {
root {
me {
name
}
}
}
`;
@helielson
helielson / migrate-to-ts.sh
Last active May 22, 2019 17:15
Rename javascript files to typescript
#!/bin/bash
set -e
echo "Rename files"
for file in $(find src/ -name "*.js" | grep -v __generated__ | grep -v __tests__); do
mv "$file" "${file%.js}.ts"
done
echo "Removing type import keyword..."
const profileInfoViewed = (fromComponent, profile) => {
const { id, name, age, homeLocation } = profile;
eventsAPI(
'ProfileInfoViewed',
fromComponent,
{ id, name, age, city: homeLocation.title }
);
};
export const profileInfoViewedFragment = graphql`
class ProfileName extends React.Component {
componentDidMount() {
profileInfoViewed('ProfileName', this.props.profile);
}
render() {
return (
<View>
<Text>{this.profile.name}</Text>
</View>
class ProfileName extends React.Component {
componentDidMount() {
profileInfoViewed('ProfileName', this.props.profile);
}
render() {
return (
<View>
<Text>{this.profile.name}</Text>
</View>
const profileInfoViewed = (fromComponent, profile) => {
const { id, name, age, homeLocation } = profile;
eventsAPI(
'ProfileInfoViewed',
fromComponent,
{ id, name, age, city: homeLocation.title }
);
};
// Based on https://github.com/facebook/relay/blob/master/packages/react-relay/modern/ReactRelayQueryRenderer.js
/**
* Copyright (c) 2013-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.
*