Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. import React, { Component } from 'react';
  2.  
  3. class Alert extends Component {
  4. render() {
  5. return (
  6. <div>
  7. <div className="alert alert-warning alert-dismissible" role="alert">
  8. <button type="button" className="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  9. {this.props.text}
  10. </div>
  11. </div>
  12. );
  13. }
  14. }
  15.  
  16. export default Alert;
  17.  
  18. import React, { Component } from 'react';
  19.  
  20. class Alert extends Component {
  21.  
  22. constructor(props, context) {
  23. super(props, context);
  24. this.state = {
  25. isActive: true,
  26. }
  27. }
  28.  
  29. hideAlert() {
  30. this.setState({
  31. isActive: false,
  32. });
  33. }
  34.  
  35. render() {
  36. if (this.state.isActive) {
  37. return (
  38. <div
  39. className="alert alert-warning alert-dismissible"
  40. role="alert"
  41. >
  42. <button
  43. type="button"
  44. className="close"
  45. data-dismiss="alert"
  46. aria-label="Close"
  47. onClick={() => this.hideAlert()}
  48. >
  49. <span aria-hidden="true">&times;</span>
  50. </button>
  51. {this.props.text}
  52. </div>
  53. );
  54. }
  55. return <div/>
  56. }
  57. }
  58.  
  59. export default Alert;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement