Skip to content

Instantly share code, notes, and snippets.

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

Luciano Lima lucianomlima

🏠
Working from home
View GitHub Profile
@Glazzes
Glazzes / App.tsx
Last active September 16, 2024 19:27
React Native pinch to zoom advanced
/**
* After some thoughts on this topic, I've decided to turn this gist along with other features into a library so you can zoom
* whatever you want, library you can find here https://github.com/Glazzes/react-native-zoom-toolkit.
*
* @author Santiago Zapata, Glazzes at Github <3
* @description This gist makes part of an article I'm writing about this topic (in spanish). This solution takes into account
* the linear algebra concepts and geometrical interpretation of the transform-origin property specification, this solution
* takes heavy inspiration from William's Candillon +3 year old video in this topic, however this solution brings it to the
* modern day along with a huge fix that prevents the origin from being displaced by an incorrect offset calculation after
* the first zoom interaction.
@sibelius
sibelius / AutocompleteRelay.tsx
Last active March 23, 2024 10:13
@material-ui Autocomplete lab with react-window + infinite-loader for GraphQL/Relay connections
import React, { useRef, useState } from 'react';
import { Typography } from '@material-ui/core';
import TextField from '@material-ui/core/TextField';
import CircularProgress from '@material-ui/core/CircularProgress';
import Autocomplete, {
AutocompleteChangeDetails,
AutocompleteChangeReason,
AutocompleteProps
} from '@material-ui/lab/Autocomplete';
@sibelius
sibelius / FeatureFlag.tsx
Created May 6, 2020 12:33
Basic Feature Flag implementation using React.Context
import React, { useContext, useCallback } from 'react';
export const FeatureFlagContext = React.createContext<string[]>([]);
export const useFeatureFlag = () => {
const features = useContext<string[]>(FeatureFlagContext);
const hasFeature = useCallback(
(feature: string) => {
return features.includes(feature);
@jgcmarins
jgcmarins / mapboxToAddress.ts
Created January 30, 2020 21:46
Mapbox helpers
import idx from 'idx';
import { ForwardFeature } from './mapboxTypes';
export interface AddressResult {
id?: string | null;
fullAddress?: string | null;
shortAddress?: string | null;
zipcode?: string | null;
street?: string | null;
@slorber
slorber / react-navigation-tree.jsx
Last active August 13, 2022 19:17
react-navigation-tree.jsx
const App = createAppContainer(
createStack({
LoggedSwitch: createSwitch({
// When user is authenticated
LoggedIn: createStack({
// The logged in root is generally a tab or drawer navigator
LoggedInRoot: createTabsOrDrawer({
@kelset
kelset / build-time-improvements.md
Last active June 21, 2023 19:25
This is kind of a blogpost about my experience of diving deep to improve some timings for an iOS React Native app

Improving times for both iOS build and CI for a React Native app

Intro

Hello there.

So, if you are here you probably saw my previous tweet where I asked for tips & tricks on improving the timing on an iOS/React Native app build time.

What will follow was how I mixed those suggestions + some good old GoogleSearch-fu + me deep diving on this for ~2 days.

@mmazzarolo
mmazzarolo / elevations.ts
Last active June 1, 2022 15:12
React-Native cross platform elevation definitions
/**
* React-Native cross-platform elevations.
* Based on https://ethercreative.github.io/react-native-shadow-generator/
*
* Usage:
* 1. Import "elevations" from this file
* import { elevations } from "config/elevations";
* 2. Use it. Assuming you need an elevation of 2 (based on the Android
* elevation standard), doing the following will cast the same shadow
* on both platforms:
@elsangedy
elsangedy / useSubmit.ts
Last active November 1, 2019 01:52
useSubmit
import { useState, useCallback } from "react";
export function useSubmit(fun: Function): [Function, boolean] {
const [pending, setPending] = useState<boolean>(false);
const submit = useCallback(
(...args) => {
if (pending) return;
const res = fun.apply(this, args);
@sibelius
sibelius / FormUseFormik.tsx
Last active April 13, 2023 20:09
Example showing how to useFormik and FormikProvider
type Props = {
};
const FormUseFormik = (props: Props) => {
const { enqueueSnackbar } = useSnackbar();
const onSubmit = (values) => {
enqueueSnackbar(`submit: ${JSON.stringify(values)}`, {
preventDuplicate: true,
persist: false,
});
@sibelius
sibelius / App.tsx
Created June 20, 2019 14:05
withProviders helper utils
const App = () => {
return (
<Providers>
<ClientRouter />
</Providers>
);
};