Skip to content

Instantly share code, notes, and snippets.

<TextInput
height={20} width={100} borderWidth={1}
borderColor="#000" marginTop={10} onChangeText={this.change}
/>
<TextInput
height={20}
width={100}
borderWidth={1}
borderColor="#000"
marginTop={10}
onChangeText={this.change}
/>
const processUserName = username => username.trim()
const processPassword = password => password.substring(0, 6)
const process = (type, value) => {
switch(type){
case 'username': return value.trim();
case 'password': return value.substring(0, 6);
}
}
@datvtwkm
datvtwkm / A.jsx
Last active August 26, 2018 05:21
// @flow
import React, {Component} from 'react';
import type {ComponentType} from 'react';
import B from './B'
class A extended Component<any> {
ref = {}
@datvtwkm
datvtwkm / hoc.js
Last active August 26, 2018 05:25
// @flow
import React, { Component } from 'react';
import type { ComponentType } from 'react';
export default WrappedComponent=> (
class EnhancedComponent extends Component<any> {
wrappedInstance: ?ComponentType<any> = null;
setWrappedInstance = (c: any) => { this.wrappedInstance = c; };
render(){
return (<WrappedComponent ref={this.setWrappedInstance} {...this.props}/>)
@datvtwkm
datvtwkm / B.jsx
Last active August 26, 2018 07:24
// @flow
import React, {Component} from 'react';
import type {ComponentType} from 'react';
import {
View,
Text
} from 'react-native';
import hoc from './hoc';
// @flow
import type { ComponentType } from 'react';
const containers = {};
export const setContainer = (newContainer: ComponentType<any>) => {
if (newContainer && newContainer.name) {
containers[newContainer.name] = newContainer;
return;
}
throw new Error('container has no name');
// @flow
import React, {Component} from 'react';
import type {ComponentType} from 'react';
import {connect} from 'redux';
import {
View,
Button,
Text
} from 'react-native';
import {
call,
put,
take,
takeLatest,
race,
select
} from 'redux-saga/effects';
import {