Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var mongoose=require('mongoose');
- mongoose.connect('mongodb://localhost/community1');
- //registerUser.js file connects to mongoose which is why it also causes an error
- import registration from './api/registerUser';
- import React, { Component } from 'react';
- import {
- TouchableHighlight,
- StyleSheet,
- Text,
- View,
- } from 'react-native';
- var t = require('tcomb-form-native');
- var mongoose = require('mongoose');
- mongoose.connect('mongodb://localhost/community1');
- import registration from './api/registerUser';
- var Form = t.form.Form;
- // here we are: define your domain model
- var Person = t.struct({
- username: t.String,
- email: t.String,
- password: t.String,
- });
- var options = {}; // optional rendering options (see documentation)
- var Register = React.createClass({
- onPress: function () {
- // call getValue() to get the values of the form
- var value = this.refs.form.getValue();
- if (value) { // if validation fails, value will be null
- console.log(value); // value here is an instance of Person
- registration.registerUser (value.username, value.password, value.email);
- }
- this.props.navigator.push({
- id:'Login'
- });
- },
- render: function() {
- return (
- <View style={styles.container}>
- {/* display */}
- <Form
- ref="form"
- type={Person}
- options={options}
- />
- <TouchableHighlight style={styles.button} onPress= {this.onPress} underlayColor='#99d9f4'>
- <Text style={styles.buttonText}>Save</Text>
- </TouchableHighlight>
- </View>
- );
- }
- });
- var styles = StyleSheet.create({
- container: {
- justifyContent: 'center',
- marginTop: 50,
- padding: 20,
- backgroundColor: '#ffffff',
- },
- title: {
- fontSize: 30,
- alignSelf: 'center',
- marginBottom: 30
- },
- buttonText: {
- fontSize: 18,
- color: 'white',
- alignSelf: 'center'
- },
- button: {
- height: 36,
- backgroundColor: '#48BBEC',
- borderColor: '#48BBEC',
- borderWidth: 1,
- borderRadius: 8,
- marginBottom: 10,
- alignSelf: 'stretch',
- justifyContent: 'center'
- }
- });
- module.exports = Register;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement