invariant java_Invariant Violation: Objects are not valid as a React child (React Native)

I'm trying to achieve a simple functionality, onPress of a button it should add placeName to place array and show it in the view but I seem to get an error, Please help

this my code,

export default class App extends Component{

state = {

placeName: "",

places: []

}

onChangeName = (val) => {

this.setState({

placeName: val

})

}

placeSubmitHandler = () => {

if(this.state.placeName === "") {

alert('enter something');

} else {

this.setState(prevState => {

return {

places: prevState.places.concat(prevState.placeName)

}

})

}

}

render() {

const placesOutput = this.state.places.map((place, i) => (

{place}

));

return (

style={{width: 300}}

value={this.state.textInput}

placeholder='enter anything'

onChange={this.onChangeName}

style={styles.placeInput}

/>

{placesOutput}

);

}

}

this is error im getting,

Invariant Violation: Objects are not valid as a React child (found: object with keys {dispatchConfig, _targetInst, _dispatchListeners, _dispatchInstances, type, target, currentTarget, eventPhase, bubbles, cancelable, timeStamp, defaultPrevented, isTrusted, nativeEvent, isDefaultPrevented, isPropagationStopped}). If you meant to render a collection of children, use an array instead.

in RCTText (at Text.js:154)

in TouchableText (at Text.js:278)

in Text (at App.js:48)

in RCTView (at View.js:45)

in View (at App.js:62)

in RCTView (at View.js:45)

in View (at App.js:51)

in App (at renderApplication.js:35)

in RCTView (at View.js:45)

in View (at AppContainer.js:98)

in RCTView (at View.js:45)

in View (at AppContainer.js:115)

in AppContainer (at renderApplication.js:34)

I'm new to react native, so I have no idea about this.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值