Skip to content

Instantly share code, notes, and snippets.

View AndreiCalazans's full-sized avatar
🏠
Working from home

Andrei Xavier de Oliveira Calazans AndreiCalazans

🏠
Working from home
View GitHub Profile
@AndreiCalazans
AndreiCalazans / createPaginationContainer.js
Created August 25, 2017 11:07
Create Pagination Container
export default createPaginationContainer(LinkList,
{
viewer: graphql`
fragment LinkList_viewer on Viewer {
allLinks(
filter: $filter,
first: $count,
after: $after,
orderBy: createdAt_DESC
) @connection(key: "LinkList_allLinks") {
@AndreiCalazans
AndreiCalazans / queryRenderer.js
Created August 25, 2017 11:12
Query Renderer
const LinkListPageQuery = graphql`
query LinkListPageQuery(
$count: Int!,
$filter: LinkFilter,
$after: String,
) {
viewer {
...LinkList_viewer
}
}
@AndreiCalazans
AndreiCalazans / paginate.js
Created August 25, 2017 11:18
load more paginate
_loadMore() {
if (!this.props.relay.hasMore()) {
console.log('Nothing more to load');
return
} else if (this.props.relay.isLoading()) {
console.log('Request is already pending');
return
}
this.props.relay.loadMore(ITEMS_PER_PAGE);
@AndreiCalazans
AndreiCalazans / Refetch.js
Created August 25, 2017 11:20
Refetch connection
_refetchConnection() {
this.props.relay.refetchConnection(10,(e) => null, {
filter: {
description_contains: this.state.filterValue,
}
});
}
@AndreiCalazans
AndreiCalazans / mapStateToPropsFLow.js
Created November 9, 2017 16:39
guideline for mapStateToProps + Flow
// @flow
type Props = {} & ReduxProps & ReduxState
const mapStateToProps = state => ({
user: state.user,
});
const mapDispatchToProps = dispatch => ({
actions: {
logout: () => dispatch(logout()),
@AndreiCalazans
AndreiCalazans / airlines.json
Last active September 20, 2024 18:53
List of Airlines 2 letter code
{
"U2": "easyjet",
"1T": "Bulgarian Air Charter",
"Q5": "40-Mile Air",
"4O": "Interjet",
"7A": "Express Air Cargo",
"JY": "Air Turks and Caicos",
"JU": "Air Serbia",
"QH": "Kyrgyzstan",
"A8": "Benin Golf Air",
class YourCoolComponent extends Component {
constructor(props) {
super(props);
this.state = {
counter: 0,
};
this.add = this.add.bind(this);
}
class YourCoolComponent extends Component {
state = {
counter: 0,
}
add = () => {
this.setState(prevState => ({ counter: prevState.counter + 1 }));
}
render () {
import { createStackNavigator } from 'react-navigation';
import Home from './Home';
import StoryBook from './StoryBook';
const navigationOptions = {
header: null,
};