я пытаюсь сделать, когда пользователь пишет что-то в textInput, эти данные должны быть загружены на статический c IP-адрес.
мой телефон будет подключен через Wi-Fi к электронике c точка доступа устройства, которая будет иметь некоторый IP-адрес c (например: http://192.168.0.1), поэтому я хочу опубликовать данные на этот IP-адрес. до сих пор я узнал, что могу использовать fetch для публикации данных, но не знаю как. Кто-нибудь может привести пример этого варианта использования?
вот мой код для компонента «Текст и кнопка».
import React, { Component } from 'react';
import {View, Text, TextInput, TouchableOpacity} from 'react-native';
export default class InputCard extends Component {
state = {
inputcontent:''
}
handleContent = (text) => {
this.setState({ inputcontent: text })
}
render() {
const {viewStyle, inputBoxStyle, touchStyle, touchText} = styles;
const {onPress} = this.props;
return (
<View style={viewStyle}>
<TextInput
style={inputBoxStyle}
underlineColorAndroid = "transparent"
placeholder = {this.props.placeHolderText}
placeholderTextColor = "#FFFFFF"
keyboardType='numeric'
selectionColor='#FFFFFF'
fontWeight='bold'
autoCapitalize = "none"
onChangeText = {this.handleContent}/>
<TouchableOpacity style={touchStyle}
onPress={() => onPress()}>
<Text style={touchText}> Submit </Text>
</TouchableOpacity>
</View>
);
}
}
и код для моего индекса. js
import React,{Component} from 'react';
import {AppRegistry, StatusBar, View, Text} from 'react-native';
import Header from './src/components/header';
import InputCard from './src/components/inputcard';
import Button from './src/components/button';
export default class Home extends Component {
render() {
const {viewStyle,subTextStyle,textWrapper,contentWrapper} = styles;
return (
<View style={viewStyle}>
<View style={contentWrapper}>
<Header headerText={'Announcer'} />
<StatusBar
backgroundColor="#263238"
barStyle='light-content'
/>
<InputCard placeHolderText={'Mp3 track number'} onPress={() => {alert("hello");}}/>
<InputCard placeHolderText={'Track length'}/>
<InputCard placeHolderText={'Owner number'}/>
<Button text={'Import Contacts'} />
<Button text={'Start Bulk Calling'} />
<Button text={'Send Bulk SMS'} />
</View>
<View style={textWrapper}>
<Text style={subTextStyle}>Made with ❤️ by Yash Balwir</Text>
</View>
</View>
);
}
}