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
import RelayEnvironmentProvider from 'react-relay/lib/relay-experimental/RelayEnvironmentProvider';
import useLazyLoadQuery from 'react-relay/lib/relay-experimental/useLazyLoadQuery';
// ScreenA
function ScreenA() {
const { root } = useLazyLoadQuery(ScreenAQuery, null, {
fetchPolicy: 'store-or-network',
});
return (
<RelayEnvironmentProvider environment={environment}>
@helielson
helielson / hook.js
Last active October 23, 2019 22:38
import useLazyLoadQuery from 'react-relay/lib/relay-experimental/useLazyLoadQuery';
function Component () {
const { root } = useLazyLoadQuery(ScreenAQuery, null, {
fetchPolicy: 'store-or-network',
});
...
}
// 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..."
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 }
);
};
export const profileInfoViewedFragment = graphql`
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.
*
@helielson
helielson / .bashrc
Created March 23, 2017 18:59 — forked from vsouza/.bashrc
Golang 1.5 setup in Mac OSX with HomeBrew. Set `GOPATH` and `GOROOT` variables in zshell or bash.
# Set variables in .bashrc file
# don't forget to change your path correctly!
export GOPATH=$HOME/golang
export GOROOT=/usr/local/opt/go/libexec
export PATH=$PATH:$GOPATH/bin
export PATH=$PATH:$GOROOT/bin