You can run the map function and output JSX for each item.
class menuScreen extends React.Component { constructor(props) { super(props) const data = store.getState(); this.state = { username: '', messages: data.messages, records: [], }; } render() { return ( <div> {this.state.records.map(record => ( <div>{record.attributes.name} {record.attributes.phone} {record.whatever}</div> )} </div> ); } }
Keep in mind that if you need a more complex HTML structure in a map function, you will have to wrap it in a single DOM node.
The full file will look like this:
render() { return ( <div className='menubox' id='menubox'> <div className='searchbar-container'> <form onSubmit={e => e.preventDefault()}> <input type='text' size='25' placeholder='Contact Last Name' onChange={this.handleChange.bind(this)} value={this.state.username}/> <button type='submit' onClick={this.onLinkClicked.bind(this)}> Search </button> </form> </div> <div> {this.state.records.map(record => ( <div>{record.attributes.name} {record.attributes.phone}</div> )} </div> </div> ); }
source share