Advertisement
Guest User

Untitled

a guest
Nov 14th, 2016
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. var mongoose=require('mongoose');
  2. mongoose.connect('mongodb://localhost/community1');
  3.  
  4. //registerUser.js file connects to mongoose which is why it also causes an error
  5. import registration from './api/registerUser';
  6.  
  7. import React, { Component } from 'react';
  8. import {
  9. TouchableHighlight,
  10. StyleSheet,
  11. Text,
  12. View,
  13. } from 'react-native';
  14.  
  15.  
  16. var t = require('tcomb-form-native');
  17. var mongoose = require('mongoose');
  18. mongoose.connect('mongodb://localhost/community1');
  19. import registration from './api/registerUser';
  20.  
  21.  
  22. var Form = t.form.Form;
  23.  
  24. // here we are: define your domain model
  25. var Person = t.struct({
  26. username: t.String,
  27. email: t.String,
  28. password: t.String,
  29. });
  30.  
  31. var options = {}; // optional rendering options (see documentation)
  32.  
  33.  
  34. var Register = React.createClass({
  35.  
  36.  
  37. onPress: function () {
  38. // call getValue() to get the values of the form
  39. var value = this.refs.form.getValue();
  40. if (value) { // if validation fails, value will be null
  41. console.log(value); // value here is an instance of Person
  42.  
  43. registration.registerUser (value.username, value.password, value.email);
  44.  
  45. }
  46. this.props.navigator.push({
  47. id:'Login'
  48. });
  49. },
  50.  
  51. render: function() {
  52. return (
  53. <View style={styles.container}>
  54. {/* display */}
  55. <Form
  56. ref="form"
  57. type={Person}
  58. options={options}
  59. />
  60. <TouchableHighlight style={styles.button} onPress= {this.onPress} underlayColor='#99d9f4'>
  61. <Text style={styles.buttonText}>Save</Text>
  62. </TouchableHighlight>
  63. </View>
  64.  
  65. );
  66. }
  67. });
  68.  
  69. var styles = StyleSheet.create({
  70. container: {
  71. justifyContent: 'center',
  72. marginTop: 50,
  73. padding: 20,
  74. backgroundColor: '#ffffff',
  75. },
  76. title: {
  77. fontSize: 30,
  78. alignSelf: 'center',
  79. marginBottom: 30
  80. },
  81. buttonText: {
  82. fontSize: 18,
  83. color: 'white',
  84. alignSelf: 'center'
  85. },
  86. button: {
  87. height: 36,
  88. backgroundColor: '#48BBEC',
  89. borderColor: '#48BBEC',
  90. borderWidth: 1,
  91. borderRadius: 8,
  92. marginBottom: 10,
  93. alignSelf: 'stretch',
  94. justifyContent: 'center'
  95. }
  96. });
  97. module.exports = Register;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement