Skip to content

Instantly share code, notes, and snippets.

View Ranatchai's full-sized avatar

Ranatchai Chernbamrung Ranatchai

View GitHub Profile
@Ranatchai
Ranatchai / app.js
Created August 9, 2019 05:14
Apollo client state Example
import { clientState } from './src/state/clientState'
const client = new ApolloClient({
clientState
})
export default class App extends React.Component {
render() {
return (
<ApolloProvider client={client}>
import React from 'react'
import { withRouter } from 'utils/native'
import { some } from 'lodash'
export const HistoryStackContext = React.createContext()
export const HistoryStackConsumer = HistoryStackContext.Consumer
export const HistoryStack = withRouter(
class HistoryStack extends React.Component {
constructor(props) {
import React from 'react'
import { withRouter } from 'react-router-dom'
import { track } from './tracker'
import { getQueryParams } from './utils/params'
import { EVENT_PAGE_VIEW } from './utils/event'
import ReactGA from 'react-ga'
export const TrackPageView = withRouter(
class TrackPageView extends React.Component {
componentDidMount() {
import React from 'react'
const MIXPANEL_TOKEN = '' // token here
const appProperties = {}
const _waitTracking = []
let mixpanel = null
let isInit = false
/*
always load mixpanel dynamic because it's huge https://github.com/mixpanel/mixpanel-js/issues/128
@Ranatchai
Ranatchai / orientation.js
Last active November 12, 2018 21:51
React Native Orientation Listener
function onOrientationChange(callback) {
Dimensions.addEventListener('change', () => {
const { width, height } = Dimensions.get('window')
const orientation = width > height ? 'landscape': 'portrait'
callback(orientation)
})
}
onOrientationChange((orientation) => {
this.setState({ orientation })
import { Progress } from 'antd'
import React, { PureComponent } from 'react'
import styled, { injectGlobal } from 'styled-components'
const StyledProgress = styled(Progress)`
display: block;
width: 200px;
margin-top: 2px;
.ant-progress-outer {
display: block;