В React native нет тегов div и form, которые заменяются на представления и ввод текста, импортированные из реагировать-native.
Я изменил ваш код, внес необходимые изменения, проверьте его один раз:
import React, { useState } from 'react';
import { ListItem } from 'react-native-elements';
import {View,Button, TextInput} from 'react-native';
export default class AddNote extends React.Component {
constructor(props) {
super(props);
this.state = {
text:"",
niz: ['test1', 'test2']
}
}
handleSubmit =()=> {
if(this.state.text !=""){
this.state.niz.push(this.state.text);
this.setState({
niz:this.state.niz
})
}
console.log(this.state.niz);
this.setState({
text:""
})
}
render() {
return (
<View style={{marginTop:"30%"}}>
{
this.state.niz.map((l, i) =>{
return(
<View>
<ListItem title={l}
bottomDivider
chevron
/>
</View>
)
})
}
<View style={{justifyContent:"center",alignItems:"center",marginTop:"5%"}}>
<TextInput style={{ width:"50%",height: 30, borderColor: "gray", borderWidth: 2,borderRadius:20,paddingLeft:20,paddingRight:20,marginBottom:10 }}
placeholder="Enter text to be added" placeholderTextColor="gray" onChangeText={(text) => this.setState({ text })} value={this.state.text}/>
<Button title ="Submit" onPress={this.handleSubmit}></Button>
</View>
</View>
);
}
}
После ввода «test3» в качестве ввода и подачи ввода
Надеюсь, это поможет!