mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Convert Alert component to use JSX (#7542)
This commit is contained in:
parent
666277b4fa
commit
22a2d21796
@ -1,18 +1,13 @@
|
|||||||
const { Component } = require('react')
|
import classnames from 'classnames'
|
||||||
const PropTypes = require('prop-types')
|
import PropTypes from 'prop-types'
|
||||||
const h = require('react-hyperscript')
|
import React, { Component } from 'react'
|
||||||
|
|
||||||
class Alert extends Component {
|
class Alert extends Component {
|
||||||
|
state = {
|
||||||
constructor (props) {
|
visible: false,
|
||||||
super(props)
|
|
||||||
|
|
||||||
this.state = {
|
|
||||||
visble: false,
|
|
||||||
msg: false,
|
msg: false,
|
||||||
className: '',
|
className: '',
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
componentWillReceiveProps (nextProps) {
|
componentWillReceiveProps (nextProps) {
|
||||||
if (!this.props.visible && nextProps.visible) {
|
if (!this.props.visible && nextProps.visible) {
|
||||||
@ -26,14 +21,14 @@ class Alert extends Component {
|
|||||||
this.setState({
|
this.setState({
|
||||||
msg: props.msg,
|
msg: props.msg,
|
||||||
visible: true,
|
visible: true,
|
||||||
className: '.visible',
|
className: 'visible',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
animateOut () {
|
animateOut () {
|
||||||
this.setState({
|
this.setState({
|
||||||
msg: null,
|
msg: null,
|
||||||
className: '.hidden',
|
className: 'hidden',
|
||||||
})
|
})
|
||||||
|
|
||||||
setTimeout(_ => {
|
setTimeout(_ => {
|
||||||
@ -45,9 +40,9 @@ class Alert extends Component {
|
|||||||
render () {
|
render () {
|
||||||
if (this.state.visible) {
|
if (this.state.visible) {
|
||||||
return (
|
return (
|
||||||
h(`div.global-alert${this.state.className}`, {},
|
<div className={classnames('global-alert', this.state.className)}>
|
||||||
h('a.msg', {}, this.state.msg)
|
<a className="msg">{this.state.msg}</a>
|
||||||
)
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
|
Loading…
x
Reference in New Issue
Block a user