Skip to content

Instantly share code, notes, and snippets.

import React, { Component } from 'react';
import { requireNativeComponent, View } from 'react-native';
import ReboundRenderer from './ReboundRenderer';
const RNTableViewChildren = requireNativeComponent('RNTableViewChildren', null);
const ROWS_FOR_RECYCLING = 20;
export default class RecyclingListView extends Component {
constructor(props) {
var React = require('React');
var ReboundRenderer = React.createClass({
propTypes: {
boundTo: React.PropTypes.number.isRequired,
render: React.PropTypes.func.isRequired,
},
shouldComponentUpdate: function(nextProps): boolean {
return nextProps.boundTo !== this.props.boundTo;
class Example extends Component {
render() {
return (
<View style={styles.container}>
<Swipeable>
<Card title='The Winds of Winter' />
</Swipeable>
<Swipeable>
import React, { Component } from 'react';
import { PanResponder, View, Dimensions } from 'react-native';
const dragOffsetForTransparency = 0.8 * Dimensions.get('window').width;
export default class Swipeable extends Component {
constructor(props) {
super(props);
this.state = {
containerOpacity: 1,
import React, { Component } from 'react';
import { PanResponder, View, Dimensions } from 'react-native';
const dragOffsetForTransparency = 0.8 * Dimensions.get('window').width;
export default class Swipeable extends Component {
constructor(props) {
super(props);
this.panResponder = PanResponder.create({
onStartShouldSetPanResponder: (evt, gestureState) => true,
#import "RNSwipeableManager.h"
#import "RNSwipeable.h"
@implementation RNSwipeableManager
RCT_EXPORT_MODULE()
- (UIView *)view {
return [[RNSwipeable alloc] init];
}
#import "RNSwipeable.h"
@interface RNSwipeable()
@property (nonatomic, assign) CGPoint initialCenter;
@property (nonatomic, assign) CGFloat dragOffsetForTransparency;
@end
@implementation RNSwipeable
- (instancetype)init {
import React, { Component } from 'react';
import { requireNativeComponent } from 'react-native';
const RNSwipeable = requireNativeComponent('RNSwipeable', null);
export default class Swipeable extends Component {
render() {
return (
<RNSwipeable>
{this.props.children}
import React, { Component } from 'react';
import { PanResponder, Animated, View, Dimensions } from 'react-native';
const dragOffsetForTransparency = 0.8 * Dimensions.get('window').width;
export default class Swipeable extends Component {
constructor(props) {
super(props);
this.state = {
containerTranslateX: new Animated.Value(0)
const _getContentOffset = Invoke.call(scrollComponent, 'contentOffset');
const {x, y} = await Invoke.execute(_getContentOffset);