Skip to content

Instantly share code, notes, and snippets.

View joshjhargreaves's full-sized avatar

Josh Hargreaves joshjhargreaves

View GitHub Profile
/** @license React v0.21.0
* react-reconciler.development.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
"use strict";
@joshjhargreaves
joshjhargreaves / readme.md
Last active September 7, 2018 04:05
Consuming Blobs in a Native Module in React Native

Blob support landed in React Native in 0.54.

In effect this means you can hold a reference in JS to a resource which exists on the native side, and pass it to a native module without needing a round trip of the serialised data over the bridge and back.

JS side, you can retrieve a blob from fetch like so, which you can then pass to your native module.

const response = await fetch(BLOB_URL);
const blob = await response.blob();
...
blob.clear();
@joshjhargreaves
joshjhargreaves / LazyLoadComponent.js
Last active July 27, 2018 16:03
Use lazy requires for screens for React Navigation
//Navigator
const SettingsScreen = createLazyComponent(
() => require('../containers/component').default
);
// ...
const MainStackNavigator = StackNavigator(
{
SettingsScreen: {
screen: SettingsScreen,
// Expo link: https://exp.host/@joshyhargreaves/inverted-flatlist
import React from 'react';
import {
ListView,
Text,
TouchableHighlight,
View,
StyleSheet,
FlatList,
ScrollView
require 'json'
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
Pod::Spec.new do |s|
s.name = "react-native-navigation"
s.version = package['version']
s.summary = "React-native navigation solution"
s.authors = { "Wix" => "Wix" }
// Copy of Exponent snack example
// https://snack.expo.io/HJcgiI8kb
import React, { Component } from 'react';
import { Text, View, FlatList, Dimensions, Button, StyleSheet } from 'react-native';
const { width } = Dimensions.get('window');
const style = {
justifyContent: 'center',
alignItems: 'center',
**setTimeout 0**
2017-05-01 22:19:53.228 [info][tid:com.facebook.react.JavaScript] 'componentDidMount setTimeout callback:', { contentLength: 0,
dOffset: 0,
dt: 10,
offset: 0,
timestamp: 0,
velocity: 0,
visibleLength: 0 }
2017-05-01 22:19:53.238 [info][tid:com.facebook.react.JavaScript] 'onContentSizeChange:', { contentLength: 15750,
dOffset: 0,
import Exponent from 'exponent';
import React from 'react';
import { range } from 'lodash';
import {
StyleSheet,
Dimensions,
ScrollView,
Animated,
Text,