Skip to content

Instantly share code, notes, and snippets.

// dependency - you need to finish load rooms before you load reservations
let roomsLoadPromise = undefined;
export function loadRooms() {
return async function (dispatch, getState) {
if (!roomsLoadPromise) {
roomsLoadPromise = dispatch(_loadRooms());
}
await roomsLoadPromise;
'use strict';
var Controllers = require('react-native-controllers');
var React = Controllers.hijackReact();
var {
ControllerRegistry,
TabBarControllerIOS,
NavigationControllerIOS,
ViewControllerIOS,
// notes:
// notice how this file is not related at all to react-native-controllers, this is how you would define a regular
// React component that's connected to a redux store
// we don't want to add react-native-controllers modifications in every one of your screens, see app.ios.js + index.ios.js
// to see how we concentrate all necessary modifications in one place
import React, {
Component,
Text,
View,
// note:
// this is the entry point for the entire app
import React, { Component, AppRegistry } from 'react-native';
import { createStore, applyMiddleware, combineReducers } from 'redux';
import { Provider } from 'react-redux';
import thunk from 'redux-thunk';
import * as reducers from './reducers';
// note:
// this code was taken almost as-is from the example project in react-native-controllers/index.ios.js
// sorry for mixing es5 and es6 syntax, but it should be very easy to upgrade the syntax here to es6
var Controllers = require('react-native-controllers');
// it's a good idea to separate all react-native-controllers specific code to a single separate file
// because we have a special React instance in this file
var React = Controllers.hijackReact();
var {
import React, { Component } from 'react';
import { Text, View, Dimensions } from 'react-native';
import RecyclingListView from './RecyclingListView';
const ROWS_IN_DATA_SOURCE = 3000;
const dataSource = [];
for (let i=0; i<ROWS_IN_DATA_SOURCE; i++) dataSource.push(`This is the data for row # ${i+1}`);
export default class RecyclingExample extends Component {
#import "RNTableViewManager.h"
#import "RNTableView.h"
@implementation RNTableViewManager
RCT_EXPORT_MODULE()
- (UIView *)view
{
return [[RNTableView alloc] initWithBridge:self.bridge];
#import "RNTableView.h"
#import "RCTConvert.h"
#import "RCTEventDispatcher.h"
#import "RCTUtils.h"
#import "UIView+React.h"
@interface RNTableView()<UITableViewDataSource, UITableViewDelegate>
@property (strong, nonatomic) UITableView *tableView;
@end
- (void)insertReactSubview:(UIView *)subview atIndex:(NSInteger)atIndex {
// will not add them as subviews yet because we don't need to draw them
// [super insertSubview:subview atIndex:atIndex];
[_unusedCells addObject:subview];
}
- (UIView*) getUnusedCell {
UIView* res = [_unusedCells lastObject];
[_unusedCells removeLastObject];
if (res != nil) {
// this is finally the full implementation of this function, all missing pieces filled in
- (UITableViewCell *)tableView:(UITableView *)theTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"CustomCell";
TableViewCell *cell = (TableViewCell *)[theTableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell = [[TableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
cell.cellView = [self getUnusedCell];
NSLog(@"Allocated childIndex %d for row %d", (int)cell.cellView.tag, (int)indexPath.row);