import React, { Component } from 'react' import { View, Text, Button, TextInput, Switch } from 'react-native' import { saveTemperature, getPreviousTemperature } from './db' export default class Temp extends Component { constructor(props) { super(props) this.cycleDay = props.cycleDay this.bringIntoView = props.bringIntoView let initialValue if(this.cycleDay.temperature) { initialValue = this.cycleDay.temperature.value.toString() } else { const prevTemp = getPreviousTemperature(this.cycleDay) initialValue = prevTemp ? prevTemp.toString() : '' } this.state = { currentValue: initialValue, exclude: this.cycleDay.temperature ? this.cycleDay.temperature.exclude : false } } render() { const cycleDay = this.cycleDay return ( Temperature { this.setState({currentValue: val}) }} keyboardType='numeric' value = {this.state.currentValue} /> Exclude { this.setState({ exclude: val }) }} value = { this.state.exclude } /> ) } }