Skip to content

Instantly share code, notes, and snippets.

View frankcalise's full-sized avatar

Frank Calise frankcalise

View GitHub Profile
@dbasedow
dbasedow / WebViewResizing.js
Last active September 26, 2022 18:55
Resize WebView to content height in react-native
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var {AppRegistry, Text, WebView, View, Dimensions} = ReactNative;
var WebViewResizing = React.createClass({
getInitialState: function () {
return {
webViewHeight: 100 // default height, can be anything
@sorenlouv
sorenlouv / determine-changed-props.js
Last active April 18, 2024 16:21
Determine which props causes React components to re-render
import React, { Component } from 'react';
export default function withPropsChecker(WrappedComponent) {
return class PropsChecker extends Component {
componentWillReceiveProps(nextProps) {
Object.keys(nextProps)
.filter(key => {
return nextProps[key] !== this.props[key];
})
.map(key => {
@gbalbuena
gbalbuena / superagent.js
Last active November 3, 2022 10:50 — forked from charleskorn/superagent.js
A Jest mock for superagent. Place in your __mocks__ directory.
llet mockDelay;
let mockError;
let mockResponse = {
get: jest.fn(),
ok: true,
status: 200,
toError: jest.fn(),
};
let mockResponseBodies;
@stolinski
stolinski / providerCompose.js
Created April 23, 2019 17:40
ProviderComposer
function ProviderComposer({ contexts, children }) {
return contexts.reduceRight(
(kids, parent) =>
React.cloneElement(parent, {
children: kids,
}),
children
);
}
@darryl-davidson
darryl-davidson / App.js
Created December 4, 2019 00:51
Example Expo 35 App that registers Background Fetch and Location Updates
import React, { useEffect } from "react";
import { StyleSheet, Text, View } from "react-native";
import * as BackgroundFetch from "expo-background-fetch";
import * as TaskManager from "expo-task-manager";
import * as Permissions from "expo-permissions";
import * as Location from "expo-location";
import { Notifications } from "expo";
import { Button } from "react-native";
const LOCATION_FETCH_TASK = "upload-job-task-with-location";
@jeffreymeng
jeffreymeng / useAuthState-introduction.md
Last active September 4, 2023 15:27
Gatsby React Firebase Authentication Hook

As opposed to useAuthState in react-firebase-hooks (which doesn't work with gatsby builds), this is designed to work with gatsby-plugin-firebase.

Requires React and firebase

Usage example:

import firebase from "gatsby-plugin-firebase"
import useAuthState from ...
@FarazPatankar
FarazPatankar / splashScreen.js
Last active October 27, 2023 09:26
Splash screen configuration for a bare expo app.
import React, { useState, useEffect } from 'react';
import { useFonts } from '@use-expo/font';
import * as SplashScreen from 'expo-splash-screen';
const App = () => {
const [isReady, setIsReady] = useState(false)
const [isLoaded] = useFonts({
'Poppins-Regular': require('./assets/fonts/Poppins-Regular.ttf'),
'Poppins-Medium': require('./assets/fonts/Poppins-Medium.ttf'),
'Poppins-SemiBold': require('./assets/fonts/Poppins-SemiBold.ttf'),

Install Android SDK CLI Ubuntu 20.04 WSL2 (Work in Progress)

Install Java 8

sudo apt install openjdk-8-jdk-headless

Android SDK

@EvanBacon
EvanBacon / RootViewBackgroundColor.tsx
Created December 10, 2021 21:44
A stack based Expo component for setting the background color of the root view. Useful for changing the background color on certain screens or inside of native modals. Updates based on Appearance and AppState.
import * as SystemUI from 'expo-system-ui';
import * as React from 'react';
import { Appearance, AppState, AppStateStatus, ColorSchemeName, ColorValue } from 'react-native';
type ThemedColorValue = { light: ColorValue, dark: ColorValue };
type Props = { backgroundColor: ColorValue | ThemedColorValue }
const propsStack: Props[] = [];
@EvanBacon
EvanBacon / withVideoImportSupport.js
Created October 13, 2022 19:26
An Expo Config Plugin that enables opening any video file type in your iOS app
// https://gist.github.com/EvanBacon/98858a341e2da209587455bbad465931
const includesEverything = {
CFBundleDocumentTypes: [
{
CFBundleTypeExtensions: ["*"],
CFBundleTypeName: "All files",
CFBundleTypeOSTypes: ["*"],
},
{
CFBundleTypeExtensions: ["mov"],