forked from kaprijela/zobro2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ios.js
executable file
·40 lines (31 loc) · 1.3 KB
/
index.ios.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import React from 'react';
import { AppRegistry } from 'react-native';
import { createStore } from 'redux';
import { Provider } from 'react-redux';
import AppReducer from './reducers';
import AppWithNavigationState from './navigation'
import { scenes } from './scenes'
import {setAnimalTab, setSelectedAnimal} from './actions';
import PouchDB from 'pouchdb-react-native';
export const localDB = new PouchDB('myDB');
const remoteDB = new PouchDB('https://admin:[email protected]/animals');
localDB.replicate.from(remoteDB); //synchronization
export var animals = [];
localDB.get('animals', {attachments : true}) // get list of animals
.then (doc => {animals.push(doc.animals)});
export default class Zobro2App extends React.Component {
store = createStore(AppReducer);
render() {
return (
<Provider store={this.store}>
<AppWithNavigationState onNavigationStateChange={(prevState, currentState) => {
if (currentState.routes[currentState.index].routeName === scenes.ANIMAL_DETAIL) {
this.store.dispatch(setSelectedAnimal(currentState.routes[currentState.index].params.animal));
this.store.dispatch(setAnimalTab('Text'));
}
}} />
</Provider>
);
}
}
AppRegistry.registerComponent('zobro2', () => Zobro2App);