Skip to content

Instantly share code, notes, and snippets.

View nandorojo's full-sized avatar

Fernando Rojo nandorojo

View GitHub Profile
@nandorojo
nandorojo / index.tsx
Last active March 5, 2024 13:07
LayoutView: Moti + Framer Motion + React Native (+ Web)
import { MotiView } from 'moti'
import { styled } from 'dripsy'
import { LayoutViewProps } from './types'
import { Layout } from 'react-native-reanimated'
const LayoutView = ({ state, layout, ...props }: LayoutViewProps) => (
<MotiView
state={state}
layout={
layout === false
@nandorojo
nandorojo / readme.md
Last active June 24, 2022 00:47
How to restart an Expo / Next.js app

If you need to restart a React Native app, and you're using Expo, then this gist will help you do it.

It also comes with web support.

Keep in mind, this will only work if you're using a custom dev client from Expo. If you aren't, then you should delete lines 11-13, and you won't be able to restart the app in dev mode.

@nandorojo
nandorojo / gist.ts
Created July 18, 2022 18:28
field.ts
export function useSellerBookingRequestPersonalized() {
const getArtistsWhoMaybeCouldBid = ({ artists, bookingRequest }) => {
return artists?.filter((artist) =>
bookingRequest?.artist_ids?.includes(artist.id)
);
};
const getAreAllMyBidsRejected = ({ artists, bookingRequest }) => {
const artistsWhoMaybeCouldBid = getArtistsWhoMaybeCouldBid({
artists,
@nandorojo
nandorojo / grid.tsx
Last active July 31, 2022 18:24
React Native Grid with Dripsy
import React from 'react'
import { View, useDripsyTheme, useResponsiveValue, Theme as DripsyTheme } from 'dripsy'
import { pickChild } from './pick-child'
type Props = {
/**
* Number of columns that should appear. If you want different columns at different screen sizes, use an array of numbers.
*/
columns?: number | number[]
children: React.ReactNode
@nandorojo
nandorojo / make-plugin.ts
Last active August 20, 2023 05:55
Add Type Safety to Expo config plugins
import { ConfigPlugin } from '@expo/config-plugins'
export const makePlugin = <F extends ConfigPlugin<any>, A extends Parameters<F>[1]>(
f: F,
a: A
): [F, A] => {
return [f, a]
}
@nandorojo
nandorojo / next.config.js
Last active January 13, 2023 19:33
next config
const withPlugins = require('next-compose-plugins')
const getTranspiledPackages = () => {
const path = require('path')
const fs = require('fs')
const node_modules = path.resolve(__dirname, '../..', 'node_modules')
const monorepoScope = '@beatgig'
@nandorojo
nandorojo / expo-ts49.md
Last active February 27, 2023 15:58
How to use TypeScript 4.9 `satisfies` with Expo SDK 47
@nandorojo
nandorojo / hover.tsx
Created February 2, 2023 16:17
Hoverable
import * as React from 'react';
import { View, StyleSheet } from 'react-native';
let isEnabled = false;
// the following logic comes from the creator of react-native-web
// https://gist.github.com/necolas/1c494e44e23eb7f8c5864a2fac66299a
// it's also used by MotiPressable's hover interactions
// https://github.com/nandorojo/moti/blob/master/packages/interactions/src/pressable/hoverable.tsx
@nandorojo
nandorojo / readme.md
Last active February 1, 2024 13:26
URQL Simple Pagination Hook implementation

This hook lets you use pagination from URQL. I needed a better solution for React Native and infinite lists.

It also has a pullToRefresh option. Since URQL's pull to refreshes are so insanely flickery, I decided to fake this completely, and make it pretend to spin for one second (plenty for most calls).

Be sure to use useMemo with your variables!

It comes with typesafety too.

const document = graphql(`
@nandorojo
nandorojo / expo-ts5.md
Last active March 30, 2023 16:40
How to use TypeScript 5.0 Beta with Expo SDK 48 or 47