私はpaho mqttを使用しています。私では、TextInputを経由してJSON配列としてクライアントにデータを送信したいが、私は未定義のデータにテキスト入力配列を使ってjson形式でデータを送信する方法
const ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
constructor(props) {
super(props);
this.state = {
listofItems: [],
text: '',
text1: '',
}}
_addTask() {
const listofItems = [...this.state.listofItems, this.state.text, this.state.text1];
this.setState({
listofItems: listofItems,
text: '',
text1: '',
});
this._changeTextInputValue('');
}
_changeTextInputValue (text) {
this.setState({
text
});
}
_changeTextInputValue1 (text1) {
this.setState({
text1
});
}
static _renderRowData (rowData) {
return (
<Text>{ rowData }</Text>
)
}
を取得していますように思える。これはテキスト入力
<TextInput autoCorrect={ false }
onChangeText={ (text) => this._changeTextInputValue(text) }
onSubmitEditing = {() => this.itemcodeDesc.focus()}
style={{backgroundColor:'#ddd'}}
value={ this.state.text }
/>
<TextInput
autoCorrect={ false }
onChangeText={ (text1) => this._changeTextInputValue1(text1) }
onSubmitEditing={() => this._addTask() }
returnKeyType={ 'done' }
ref={(input) => this.itemcodeDesc = input}
style={{backgroundColor:'#ddd'}}
value={ this.state.text1 }
/>
そしてボタンです:
<TouchableHighlight style={styles.button} onPress={this.sendMessage} underlayColor="transparent">
<Text style={styles.buttonText}>NEXT</Text>
</TouchableHighlight>
が、私はこの
"items": [{"itemcode":"'+this.state.listofItems[]+'"}]
を呼び出すように私は、JSON形式で項目の配列を取得カント
in sendMessage関数。誰もこれを行う方法を知っていますか?
誰でも助けてくれますか?私はまだこれに問題があります。事前にありがとうございます。 – kkumber