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.