Skip to content

Instantly share code, notes, and snippets.

View Grohden's full-sized avatar
:shipit:
*tec tec tec noises*

Gabriel Rohden Grohden

:shipit:
*tec tec tec noises*
View GitHub Profile
@Grohden
Grohden / managed-view-renderer.tsx
Last active February 27, 2025 14:03
A way to render a view (like a portal) and get a result out of it (similar to react-native-use-modal)
import {
Fragment,
type ReactNode,
createContext,
useCallback,
useContext,
useEffect,
useMemo,
useState,
} from 'react';
import fs from 'fs';
import path from 'path';
import { globSync } from 'glob';
const isCI = process.env.CI === '1' || process.env.CI === 'true';
const silent = process.argv.indexOf('--silent') !== -1 || isCI;
const fileArgIndex = process.argv.indexOf('--file');
const singleFilePath =
fileArgIndex !== -1 ? process.argv[fileArgIndex + 1] : null;
@Grohden
Grohden / eas-build-pre-install.js
Last active January 29, 2025 10:55
ssh setup for private repo usages in expo eas
const { execSync } = require('child_process');
const fs = require('fs');
const path = require('path');
function present(value) {
return value !== null && value !== undefined && value !== '';
}
console.log('Enabling corepack for yarn v4');
execSync('corepack enable && corepack prepare [email protected] --activate', {
@Grohden
Grohden / version_synchronizer.rb
Last active January 13, 2025 14:19
A rb script to sync app.json (expo) version into native project files
require 'json'
class BaseFileManager
attr_reader :file_path
def initialize(file_path)
@file_path = file_path
end
def content
@Grohden
Grohden / expo-issue.md
Last active January 14, 2025 20:15
Description of an issue that I had with expo cli

First of all: I'm writting this one to help people (I'm hoping google indexes it)

Recently, with AppCenter being deprecated we've started migrating to expo EAS, we also wanted to "use expo", and that means we'll need to setup expo modules, which I did following the tutorial

However, after successfuly compiling to iOS, I had issues in android, one very annoying one was EarlyJSError: unexpected token "." stack, it made me lose 3 days of my sanity due to various factors

Anyway, the problem is that, by following expo tutorial, I've ran their cli and it changed our getJSMainModuleName to:

@Grohden
Grohden / hermes-ready-datefns.ts
Last active December 19, 2024 12:39
Is react native hermes ready to be used, in any normal env that uses these libs?
// Once you think you're ready for hermes, you can include this file in the app
// and if it doesn't throw an error, you're good to go.
// https://github.com/facebook/hermes/issues/865
export const areWeReadyForHermesDatefns = () => {
const anyFailed = [
// This one just throws ¯\_(ツ)_/¯
testEq(
"new Date('July 30, 2022').toISOString()",
new Date('July 30, 2022').toISOString(),
'2022-07-30T03:00:00.000Z',
@Grohden
Grohden / use-request-permission-flow.ts
Created November 26, 2024 13:28
Hook to handle the permission flow of the react-native-permissions package
import { Permission, RESULTS, check, request } from 'react-native-permissions';
import { useCallback } from 'react';
export const useRequestPermissionFlow = () => {
return useCallback(
async (
permission: Permission,
callbacks: {
onFeatureUnavailable: () => Promise<void>;
onPermissionGranted: (type: 'limited' | 'granted') => Promise<void>;
@Grohden
Grohden / readme.md
Created November 14, 2024 17:20
Exploring react native alternative dev commands

I've recently got annoyed that I had to do manual reloads (usually click focus simulatro + cmd+ctrl+z + click reload + click focus IDE) from outside of my IDE, so here's my little adventure trying to make a shortcut that interacts with the simulator or the android emulator in jetbrains

For android we have a solution straightforward solution, just run an adb command and add it as an external tool + hook into the shortcut:

adb shell input keyevent 82
@Grohden
Grohden / refactor-import.ts
Created October 29, 2024 16:47
Refactor import change module in TS using ts-morph
import path from 'path';
import { Project } from 'ts-morph';
const targetModule = 'OLD_PACKAGE';
const targetNamedImport = 'Loading';
const newNamedImport = 'Loading';
const newImportModule = 'NEW_IMPORT';
const project = new Project({
tsConfigFilePath: path.join(__dirname, '../tsconfig.json'),
@Grohden
Grohden / index.ts
Last active January 21, 2024 00:16
My "port" fo the Vibrant lib for react native
import VibrantCore from '@vibrant/core';
import { pipeline } from './pipeline.ts';
import { ReactNativeImage } from './react-native-image.ts';
export const Vibrant = VibrantCore;
// Don't forget to add this to your app root:
// useEffect(() => {