Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React, { Component } from 'react';
- class Alert extends Component {
- render() {
- return (
- <div>
- <div className="alert alert-warning alert-dismissible" role="alert">
- <button type="button" className="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
- {this.props.text}
- </div>
- </div>
- );
- }
- }
- export default Alert;
- import React, { Component } from 'react';
- class Alert extends Component {
- constructor(props, context) {
- super(props, context);
- this.state = {
- isActive: true,
- }
- }
- hideAlert() {
- this.setState({
- isActive: false,
- });
- }
- render() {
- if (this.state.isActive) {
- return (
- <div
- className="alert alert-warning alert-dismissible"
- role="alert"
- >
- <button
- type="button"
- className="close"
- data-dismiss="alert"
- aria-label="Close"
- onClick={() => this.hideAlert()}
- >
- <span aria-hidden="true">×</span>
- </button>
- {this.props.text}
- </div>
- );
- }
- return <div/>
- }
- }
- export default Alert;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement