Skip to content

Instantly share code, notes, and snippets.

@franzejr
franzejr / FakeApi.js
Created July 7, 2016 13:40
Fake API JS
import axios from 'axios';
const BASE_URL = 'https://fakeApi/api';
const loginUrl = `${BASE_URL}/request_token`;
const instance = axios.create({
baseURL: `${BASE_URL}`,
});
@franzejr
franzejr / TabView.js
Last active July 7, 2016 13:02
TabView
import React, { PropTypes } from 'react';
import { StyleSheet, View } from 'react-native';
import Button from 'react-native-button';
import { Actions } from 'react-native-router-flux';
const contextTypes = {
drawer: React.PropTypes.object,
};
const propTypes = {
import React from 'react';
import {
StyleSheet,
Text,
View,
} from 'react-native';
const styles = StyleSheet.create({
container: {
flex: 1,
@franzejr
franzejr / App.js
Created July 7, 2016 12:35
App JS using react-native-router-flux
import React, { Component } from 'react';
import { Router, Scene } from 'react-native-router-flux';
import MainScreen from './MainScreen/MainScreen';
import SettingsScreen from './SettingsScreen/SettingsScreen';
import LoginScreen from './LoginScreen/LoginScreen';
import SimpleDrawer from './SimpleDrawer/SimpleDrawer';
class App extends Component {
@franzejr
franzejr / index.ios.js
Created July 7, 2016 12:14
Index iOS - React Native Starter App
import React from 'react';
import {
AppRegistry,
} from 'react-native';
import App from './src/components/App';
const starterApp = () => {
return (
<App />
);
@franzejr
franzejr / RefreshReactNative.js
Created July 6, 2016 13:41
Pull Refresh React Native
<ScrollView
style={styles.scrollview}
refreshControl={
<RefreshControl
refreshing={this.state.isRefreshing}
onRefresh={this._onRefresh}
tintColor="#ff0000"
title="Loading..."
titleColor="#00ff00"
colors={['#ff0000', '#00ff00', '#0000ff']}
@franzejr
franzejr / index.html
Created June 6, 2016 12:30
Simple example using Redux and React - dispatching actions
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/redux/3.3.1/redux.js"></script>
<script src="https://fb.me/react-0.14.7.js"></script>
<script src="https://fb.me/react-dom-0.14.7.js"></script>
</head>

Keybase proof

I hereby claim:

  • I am franzejr on github.
  • I am franzejr (https://keybase.io/franzejr) on keybase.
  • I have a public key whose fingerprint is 10C9 9C7A 2CF2 0AD2 3A21 65B4 3A9F CF1C 1119 4253

To claim this, I am signing this object:

@franzejr
franzejr / good_component.js
Created April 27, 2016 02:43
Good Component
var GoodComponent = withScroll(React.createClass({
getInitialState: function() {
return {
someNewState: ''
}
},
componentWillReceiveProps: function(nextProps) {
var {scroll} = this.props;
// do something with scroll props
@franzejr
franzejr / my_wrong_component2.js
Created April 27, 2016 02:07
Wrong Component using jQuery
var myWrongComponent2 = React.createClass({
changeVisibility: function(scroll){
if (scroll >= 100) {
$(".my-fixed-div").css('visibility', 'visible');
}
else{
$(".my-fixed-div").css('visibility', 'hidden');
}
},
handleScroll: function () {