Advertisement
Guest User

Untitled

a guest
Apr 20th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. import React, { Component } from 'react'
  2. import { Alert } from '@blueprintjs/core'
  3.  
  4. import ModalManager from './modalManager'
  5.  
  6. class Example extends Component {
  7. handle = (modal) => async () => {
  8. const result = await modal.result()
  9. alert(result)
  10. }
  11.  
  12. render () {
  13. return (
  14. <div>
  15. <button onClick={this.handle(this.modal1)}>Open Modal 1</button> <button onClick={this.handle(this.modal2)}>Open Modal 2</button>
  16. <hr />
  17. <ModalManager ref={el => this.modal1 = el}>
  18. {({ open, handleAction }) => (
  19. <Alert
  20. cancelButtonText='Cancel'
  21. confirmButtonText='Confirm'
  22. isOpen={open}
  23. onCancel={handleAction('cancel 1')}
  24. onConfirm={handleAction('confirm 1')}
  25. >
  26. <p>Are you sure?</p>
  27. </Alert>
  28. )}
  29. </ModalManager>
  30. <ModalManager ref={el => this.modal2 = el}>
  31. {({ open, handleAction }) => (
  32. <Alert
  33. cancelButtonText='Cancel'
  34. confirmButtonText='Confirm'
  35. isOpen={open}
  36. onCancel={handleAction('cancel 2')}
  37. onConfirm={handleAction('confirm 2')}
  38. >
  39. <p>Are you sure?</p>
  40. </Alert>
  41. )}
  42. </ModalManager>
  43. </div>
  44. )
  45. }
  46. }
  47.  
  48. export default Example
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement