Guest User

Untitled

a guest
Dec 17th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. <Modal
  2. isOpen={this.state.modalIsOpen}
  3. onAfterOpen={this.afterOpenModal}
  4. onRequestClose={this.closeModal}
  5. chosenBeer={this.state.chosenBeer}
  6. >
  7. <h2> == Dynamically changing title of element == </h2>
  8. <button onClick={this.closeModal}>X</button>
  9. <img src="{ == Dynamically changing image == }" />
  10. </Modal>
  11.  
  12. <div id="splashElements">
  13. {
  14. this.state.elements &&
  15. this.state.elements.map((item, index) => {
  16. return(<SingleElement key={index} name={item.name} href={item.href} image={item.image_url} tagline={item.tagline} onDelete={id => this.onDelete(index)} openModal={elementId => this.openModal(index)}/>)
  17. })
  18. }
  19. </div>
  20.  
  21. openModal = (beerId) => {
  22. this.setState({modalIsOpen: true, chosenBeer: this.state.beers[beerId]});
  23. }
  24.  
  25. afterOpenModal = () =>{
  26. // references are now sync'd and can be accessed.
  27. }
  28.  
  29. closeModal = () => {
  30. this.setState({modalIsOpen: false});
  31. }
Add Comment
Please, Sign In to add comment