Skip to content

Instantly share code, notes, and snippets.

View nandorojo's full-sized avatar

Fernando Rojo nandorojo

View GitHub Profile
nandorojo / provider.native.tsx
Last active August 26, 2023 21:31
Next.js / Solito canGoBack()
View provider.native.tsx
// this won't ever get imported on native, but we put this file here to make that clear
export default ({children}) => children
nandorojo /
Last active June 8, 2023 19:22
I learned React Native as a web developer, and I got everything wrong

When I built my first React Native app, I had some some Web experience. Using React on iOS and Android felt like an easy way to apply my skills.

But I was suprised to learn, the hard way, that my Web-developer-way-of-thinking didn't apply to Native apps.

Let's start with the navigation layout. Each website has unique page primitives. The header at the top of the page, the sidebar menu, the footers – they're all hand-rolled.

You write a <header> and all you get is an empty box. Your then use your own JavaScript and CSS to make these elements useful.

The way these elements function are part of your brand. If your header looks just like another website, something feels off.

View theme.ts
import {
} from '@tamagui/create-theme'
import { mauve, slate, mauveDark, slateDark } from '@tamagui/colors'
nandorojo /
Last active April 20, 2023 15:40
How to rename an NPM package in your `package.json`

Add the package name you want to your package.json dependencies, and then make the value npm:<actual-package-name>. You can also add a version to the end.


  "dependencies": {
    "moti18": "npm:moti@0.18.0"
nandorojo /
Last active September 26, 2023 20:47
How to create an iOS Widget with React Native (Expo / EAS)

First, copy the config plugin from this repo:

You can reference my PRs there too (which, at the time of writing, aren't merged).

After adding the config plugin (see app.json) with your dev team ID, as well as a bundle ID, you can edit the widget folder to edit your code. Then npx expo run:ios (or npx expo run:android).


After npx expo run:ios, open the ios folder, and open the file that ends in .xcworkspace in XCode. Make sure you have the latest macOS and XCode versions. If you don't, everything will break.

nandorojo / rhf.ts
Created March 29, 2023 18:40
React Hook Form TypeScript Wrapper
View rhf.ts
import {
nandorojo / eas-update-sentry.ts
Last active September 25, 2023 14:01
EAS Update + Sentry Source Maps
View eas-update-sentry.ts
import { getConfig } from '@expo/config'
import fs from 'fs'
import spawnAsync from '@expo/spawn-async'
import chalk from 'chalk'
import path from 'path'
const appDir = process.cwd()
console.log('Sentry source maps script. Working directory:'))
nandorojo /
Last active March 30, 2023 16:40
How to use TypeScript 5.0 Beta with Expo SDK 48 or 47
nandorojo /
Last active August 24, 2023 22:01
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).

It comes with typesafety too.

const document = graphql(`
  query Users($limit: Int!, $offset: Int!) {
 users(limit: $limit, offset: $offset) {
nandorojo / hover.tsx
Created February 2, 2023 16:17
View hover.tsx
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
// it's also used by MotiPressable's hover interactions