Skip to content

Instantly share code, notes, and snippets.

View ide's full-sized avatar
📈
My life is a hackathon

James Ide ide

📈
My life is a hackathon
View GitHub Profile
@ide
ide / Babel.js
Created December 2, 2015 21:37
Decorators with Babel 6 and React Native
/**
* Sample React Native App
* https://github.com/facebook/react-native
*/
'use strict';
var React = require('react-native');
var {
AppRegistry,
StyleSheet,
@ide
ide / gist:60a5fb5a5352226a4e1e
Created November 19, 2015 03:53
React Native E2E test error
ide:react-native·master$ ./scripts/e2e-test.sh
> [email protected] install /Users/ide/.nvm/versions/node/v4.2.1/lib/node_modules/sinopia/node_modules/crypt3
> node-gyp rebuild
CXX(target) Release/obj.target/crypt3/crypt3.o
In file included from ../crypt3.cc:7:
../node_modules/nan/nan.h:261:25: error: redefinition of '_NanEnsureLocal'
NAN_INLINE v8::Local<T> _NanEnsureLocal(v8::Local<T> val) {
^
@ide
ide / HomeRouteWithFocus.js
Last active October 19, 2015 09:19
Showing the focus and blur methods on a route
function getHomeRoute() {
return {
// Implement onWillFocus, onDidFocus, onWillBlur, or onDidBlur
onWillFocus(event) {
// The event is the one from React Native's Navigator. See the source code
// for what properties it has.
},
};
}
@ide
ide / TopLevelNavigator.js
Created October 19, 2015 08:54
Example with a top-level navigator presenting a modal screen
class Root extends React.Component {
render() {
// Hide the navigation bar in the top-level navigator. The main route will
// render a nested navigator with its own navigation bar.
return (
<ExNavigator
showNavigationBar={false}
initialRoute={getMainRoute()}
/>
);
@ide
ide / RouteWithEventEmitter.js
Last active April 13, 2016 00:11
Using an event emitter to communicate between the scene and navigation bar button
function getProfileRoute(user) {
let emitter = new EventEmitter();
return {
renderScene(navigator) {
let ProfileScreen = require('./ProfileScreen');
return (
<ProfileScreen
user={user}
navigator={navigator}
routeEvents={emitter}
@ide
ide / ProfileRoute.js
Last active October 19, 2015 07:13
Showing how a function creates a parameterized route
function getProfileRoute(user) {
return {
renderScene(navigator) {
let ProfileScreen = require('./ProfileScreen');
return <ProfileScreen user={user} navigator={navigator} />;
},
getTitle() {
return user.fullName;
},
@ide
ide / ExNavigatorExample.js
Created October 19, 2015 06:12
An example of setting up ExRoute
render() {
let navigationBarHeight = 64;
return (
<ExNavigator
initialRoute={homeRoute}
style={{ flex: 1 }}
sceneStyle={{ paddingTop: navigationBarHeight }}
/>
);
}
@ide
ide / HomeRoute.js
Last active February 24, 2016 16:11
Simple example of an ExRoute object
let homeRoute = {
getSceneClass() {
return require('./HomeScreen');
},
getTitle() {
return 'Home',
},
renderLeftButton(navigator) {
@ide
ide / .eslintrc
Created August 17, 2015 21:01
.eslintrc
{
"parser": "babel-eslint",
"ecmaFeatures": {
"jsx": true
},
"env": {
"es6": true,
"jasmine": true,
@ide
ide / _.js
Last active August 29, 2015 14:24
Issues with decorators and higher-order components
// @connect is a decorator provided by Redux that returns a new class that wraps
// the one defined below. Somewhat unintuitively but understandably, "Example"
// refers to the wrapper component returned from the decorator, not the wrapped
// component defined below.
@connect(data => ({ }))
class Example extends React.Component {
static staticMethod() {}
instanceMethod() {}