Skip to content

Instantly share code, notes, and snippets.

View juanchoperezj's full-sized avatar
🇻🇪

Juan Simón juanchoperezj

🇻🇪
View GitHub Profile
import React from "react";
import {
View,
SafeAreaView,
useWindowDimensions,
TextInput,
} from "react-native";
import Animated, {
Extrapolate,
interpolate,
@MarceloPrado
MarceloPrado / ReactNativeGlobalAlert.tsx
Created August 8, 2023 11:05
This gist describes how to build a global alert system that follows a similar API as RN's Alert.alert(). It can be cleaned up and improved, especially in the GlobalAlertManager side, but it's a good starting point.
import { BottomSheetModalProvider } from "@gorhom/bottom-sheet";
/**
* This gist describes how to build a global alert system that follows a similar
* API as RN's Alert.alert().
*
* This can be cleaned up and improved, especially in the GlobalAlertManager
* side, but it's a good starting point.
*/
@r0b0t3d
r0b0t3d / useCallback.md
Created July 10, 2021 09:06
Use of useCallback and useMemo

1. Use

1.1. in callback

const handlePress = useCallback(() => {
	// handle press
}, [])

Good 👍

<Button onPress={handlePress} />
@cawfree
cawfree / case.js
Last active July 16, 2024 21:26
Convert between Camel Case (camelCase) and Snake Case (snake_case) in ES6
export const toCamelCase = (e) => {
return e.replace(/_([a-z])/g, (g) => g[1].toUpperCase());
};
export const toSnakeCase = (e) => {
return e.match(/([A-Z])/g).reduce(
(str, c) => str.replace(new RegExp(c), '_' + c.toLowerCase()),
e
)
.substring((e.slice(0, 1).match(/([A-Z])/g)) ? 1 : 0);
@jtibbertsma
jtibbertsma / actions.js
Last active December 28, 2020 06:23
react-native-navigation redux middleware example
import { createAction } from 'redux-actions';
import {
NAVIGATION_PUSH,
NAVIGATION_POP,
NAVIGATION_RESET_TO,
NAVIGATION_POP_TO_ROOT
} from './actions';
export const push = createAction(NAVIGATION_PUSH);
export const pop = createAction(NAVIGATION_POP);
@asciimike
asciimike / firebase_storage_multi_file_upload.js
Last active November 29, 2021 18:05
Upload multiple files transactionally in Firebase Storage
// set it up
firebase.storage().ref().constructor.prototype.putFiles = function(files) {
var ref = this;
return Promise.all(files.map(function(file) {
return ref.child(file.name).put(file);
}));
}
// use it!
firebase.storage().ref().putFiles(files).then(function(metadatas) {