Skip to content

Instantly share code, notes, and snippets.

View lucianomlima's full-sized avatar
👨‍💻

Luciano Lima lucianomlima

👨‍💻
View GitHub Profile
@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>
);
};
@sibelius
sibelius / useEventEmitter.tsx
Created April 16, 2019 01:20
UseEventEmitter hook to work with react navigation navigationOptions buttons
import { useEffect, useRef } from 'react';
export const useEventEmitter = (eventEmitter, eventName: string, fn: () => void) => {
const subscription = useRef(null);
useEffect(() => {
subscription.current = eventEmitter.addListener(eventName, fn);
return () => {
if (subscription.current) {