Skip to content

Instantly share code, notes, and snippets.

Avatar
🐦
Follow on Twitter

Bruno Lemos brunolemos

🐦
Follow on Twitter
View GitHub Profile
@brunolemos
brunolemos / destructuring.js
Last active Sep 14, 2016 — forked from mikaelbr/destructuring.js
Several demos and usages for ES6 destructuring. Runnable demos and slides about the same topic: http://git.mikaelb.net/presentations/bartjs/destructuring
View destructuring.js
// === Arrays
var [a, b] = [1, 2];
console.log(a, b);
//=> 1 2
// Use from functions, only select from pattern
var foo = () => [1, 2, 3];
View keybase.md

Keybase proof

I hereby claim:

  • I am brunolemos on github.
  • I am brunolemos (https://keybase.io/brunolemos) on keybase.
  • I have a public key whose fingerprint is CCB7 2FCA 5650 3F50 EEB4 F796 0A8E 45A6 ACE6 6963

To claim this, I am signing this object:

@brunolemos
brunolemos / ListView.js
Last active Nov 24, 2017
React Native - ListView receiving data as a prop <ListView data={[1,2,3]} />
View ListView.js
import React from 'react';
import { ListView } from 'react-native';
export default class extends React.PureComponent {
constructor(props) {
super(props);
const { data, dataSource, rowHasChanged: _rowHasChanged } = props;
this.state.data = data || [];
@brunolemos
brunolemos / App.js
Last active Dec 10, 2017
HoC with custom prop name
View App.js
@withTest('myNewPropName')
export default class App extends PureComponent...
@brunolemos
brunolemos / Example.jsx
Last active Jan 12, 2018
[react-native] Cross-platform TabView component with unified API for SegmentedControl (iOS default) and scrollable tabs (Android default)
View Example.jsx
// Live demo: https://snack.expo.io/@brunolemos/tabview
import React, { Component } from 'react';
import { Platform, StyleSheet, View } from 'react-native';
import { Constants } from 'expo';
import TabView from './components/TabView';
const routes = [{ index: 0, title: 'Tab 0' }, { index: 1, title: 'Tab 1' }];
@brunolemos
brunolemos / TouchableScale.tsx
Created Sep 21, 2018
Touchable component with Scale effect, common on iOS 12 (works on mobile and web)
View TouchableScale.tsx
// Demo: https://snack.expo.io/@brunolemos/touch-button-scale-effect
import React from 'react'
import { Animated, StyleProp, TouchableWithoutFeedback, TouchableWithoutFeedbackProps, ViewStyle } from 'react-native'
import { styleMerge } from 'shared/src/utils'
export interface TouchableScaleProps extends TouchableWithoutFeedbackProps {
containerStyle?: StyleProp<ViewStyle>
}
@brunolemos
brunolemos / PlatformTouchable.tsx
Last active Sep 28, 2019
TypeScript version of react-native-platform-touchable
View PlatformTouchable.tsx
// Source: https://github.com/react-community/react-native-platform-touchable
import React, { PureComponent, ReactNode } from 'react'
import {
BackgroundPropType,
Platform,
StyleProp,
TouchableNativeFeedback,
TouchableNativeFeedbackProperties,
TouchableNativeFeedbackStatic,
TouchableOpacity,
@brunolemos
brunolemos / App.tsx
Last active Apr 7, 2020
react-native-safe-area-context
View App.tsx
import React from 'react'
import { StatusBar, Text, View } from 'react-native'
import { useSafeArea } from 'react-native-safe-area-context'
export function App() {
const safeAreaInsets = useSafeArea()
return (
<View
style={{
@brunolemos
brunolemos / ExampleComponent.tsx
Last active May 27, 2020
Redux + TypeScript - Strongly Typed
View ExampleComponent.tsx
import React from 'react'
import { Button, Text, View } from 'react-native'
import { useDispatch } from 'react-redux'
import { useReduxState } from '../hooks/use-redux-state'
import * as actions from '../redux/actions'
import * as selectors from '../redux/selectors'
export function LoginScreen() {
const dispatch = useDispatch()
@brunolemos
brunolemos / v1.tsx
Created Dec 17, 2019
useWhyDidYouUpdate
View v1.tsx
import { useEffect, useRef } from 'react'
export function useWhyDidYouUpdate(name: string, props: Record<string, any>) {
const latestProps = useRef(props)
useEffect(() => {
const allKeys = Object.keys({ ...latestProps.current, ...props })
const changesObj: Record<string, { from: any; to: any }> = {}
allKeys.forEach(key => {
You can’t perform that action at this time.