Merges
This commit is contained in:
@@ -24,6 +24,7 @@ export class BoundInput extends React.Component {
|
||||
const { name, binder } = this.props
|
||||
|
||||
this.state = binder.getFieldState(name)
|
||||
this.handleChangeText = this.handleChangeText.bind(this)
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
@@ -32,12 +33,12 @@ export class BoundInput extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
@autobind
|
||||
// @autobind : There seems to be a bug with using this here, so we just do it the old way
|
||||
handleChangeText(newText) {
|
||||
if (this && this.props && this.props.binder) {
|
||||
this.setState(
|
||||
this.props.binder.updateFieldValue(this.props.name, newText)
|
||||
)
|
||||
const { binder, name } = this.props
|
||||
|
||||
if (binder) {
|
||||
this.setState(binder.updateFieldValue(name, newText))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
import React from "react"
|
||||
import PropTypes from "prop-types"
|
||||
import { View, Text, TouchableHighlight } from "react-native"
|
||||
import autobind from "autobind-decorator"
|
||||
|
||||
export class BoundText extends React.Component {
|
||||
static propTypes = {
|
||||
name: PropTypes.string.isRequired,
|
||||
label: PropTypes.string,
|
||||
value: PropTypes.string,
|
||||
binder: PropTypes.object.isRequired,
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
super(props)
|
||||
|
||||
const { name, binder } = this.props
|
||||
|
||||
binder.addListener(name, this.updateValue)
|
||||
this.state = binder.getFieldState(name)
|
||||
}
|
||||
|
||||
@autobind
|
||||
updateValue(e) {
|
||||
this.setState(e.state)
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
this.props.binder.removeListener(this.props.name, this.updateValue)
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
if (nextProps.binder !== this.props.binder) {
|
||||
this.props.binder.removeListener(this.props.name, this.updateValue)
|
||||
nextProps.binder.addListener(nextProps.name, this.updateValue)
|
||||
this.setState(nextProps.binder.getFieldState(nextProps.name))
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
const { name, label, value } = this.props
|
||||
const { visible, disabled } = this.state
|
||||
|
||||
if (!visible) {
|
||||
return null
|
||||
}
|
||||
|
||||
return (
|
||||
<View>
|
||||
<Text style={{ color: "black", fontSize: 14, marginBottom: 5 }}>
|
||||
{label}
|
||||
</Text>
|
||||
<Text
|
||||
style={{
|
||||
paddingLeft: 5,
|
||||
paddingRight: 5,
|
||||
borderColor: "gray",
|
||||
borderWidth: 1,
|
||||
fontSize: 16,
|
||||
paddingTop: 7,
|
||||
paddingBottom: 7,
|
||||
}}>
|
||||
{value}
|
||||
</Text>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user