Skip to content

Instantly share code, notes, and snippets.

View omeileo's full-sized avatar
💭
`$ brew creating something amazing`

Jase-Omeileo West omeileo

💭
`$ brew creating something amazing`
View GitHub Profile
@omeileo
omeileo / App.js
Last active July 21, 2019 14:42
Closing React Native Android App with Back Button (Using react-native-router-flux)
import { BackHandler } from 'react-native'
import { Actions, Router } from 'react-native-router-flux'
class App extends Component {
componentDidMount () {
this.backHandler = BackHandler.addEventListener('hardwareBackPress', this.handleBackPress)
}
componentWillUnmount() {
this.backHandler.remove()
@omeileo
omeileo / functions.js
Last active November 2, 2021 06:21
Get Previous Scene: React native router flux (4.0.0-beta.28)
import { Actions } from 'react-native-router-flux'
export function getPreviousScene (jumpCount = 1) { // if nothing is passed, it defaults to 1
const index = Actions.prevState.routes.length - (jumpCount + 1) // because zero-based index
if (index >= 0) {
return Actions.prevState.routes[index].routeName
}
return 'home'
@omeileo
omeileo / Form.component.js
Created April 22, 2019 19:51
Navigate to next form field onSubmitEditing (React Native)
// External Dependencies
import React, { Component } from 'react'
import { View } from 'react-native'
import PropTypes from 'prop-types'
import _ from 'lodash'
// Internal Dependencies
import FormField from './FormField/FormField.component'
import styles from './Form.styles'
@omeileo
omeileo / arrayElementsSeparator.js
Last active February 9, 2019 21:20
Separate array elements using correct English grammar.
const fruits = ['apple', 'banana', 'orange', 'jackfruit']
let separatedList = ''
fruits.forEach((fruit, index) => {
const isSeparated = fruits.length > 1 && (index + 1 < fruits.length)
const isCommaSeparated = isSeparated && (index + 2 < fruits.length)
const isAmpersandSeparated = isSeparated && (index + 2 === fruits.length)
separatedList = separatedList + fruit
@omeileo
omeileo / LandingPage.component.js
Last active August 26, 2018 23:54
Floating Animating Header with Scrolling Content (React Native)
import React, { Component } from 'react'
import { Animated, ScrollView, StyleSheet, View } from 'react-native'
const HEADER_MAX_HEIGHT = 350
const HEADER_MIN_HEIGHT = 175
const SEARCH_AREA_HEIGHT = 100
const SEARCH_AREA_MAX_TOP = HEADER_MAX_HEIGHT - (SEARCH_AREA_HEIGHT / 2)
const SEARCH_AREA_MIN_TOP = 120
export default class App extends Component {