diff --git a/client/modules/IDE/components/Toast.jsx b/client/modules/IDE/components/Toast.jsx index 9f29dc1872..0f16282220 100644 --- a/client/modules/IDE/components/Toast.jsx +++ b/client/modules/IDE/components/Toast.jsx @@ -1,20 +1,23 @@ -import PropTypes from 'prop-types'; import React from 'react'; -import { bindActionCreators } from 'redux'; -import { connect } from 'react-redux'; +import { useDispatch, useSelector } from 'react-redux'; import { useTranslation } from 'react-i18next'; -import * as ToastActions from '../actions/toast'; +import { hideToast } from '../actions/toast'; import ExitIcon from '../../../images/exit.svg'; -function Toast(props) { +export default function Toast() { + const { text, isVisible } = useSelector((state) => state.toast); + const dispatch = useDispatch(); const { t } = useTranslation(); + if (!isVisible) { + return null; + } return (
-

{t(props.text)}

+

{t(text)}

); } - -Toast.propTypes = { - text: PropTypes.string.isRequired, - hideToast: PropTypes.func.isRequired -}; - -function mapStateToProps(state) { - return state.toast; -} - -function mapDispatchToProps(dispatch) { - return bindActionCreators(ToastActions, dispatch); -} - -export default connect(mapStateToProps, mapDispatchToProps)(Toast); diff --git a/client/modules/IDE/pages/IDEView.jsx b/client/modules/IDE/pages/IDEView.jsx index 04bbb2f9ad..bada353c34 100644 --- a/client/modules/IDE/pages/IDEView.jsx +++ b/client/modules/IDE/pages/IDEView.jsx @@ -26,7 +26,6 @@ import * as ProjectActions from '../actions/project'; import * as EditorAccessibilityActions from '../actions/editorAccessibility'; import * as PreferencesActions from '../actions/preferences'; import * as UserActions from '../../User/actions'; -import * as ToastActions from '../actions/toast'; import * as ConsoleActions from '../actions/console'; import { getHTMLFile } from '../reducers/files'; import Overlay from '../../App/components/Overlay'; @@ -255,7 +254,7 @@ class IDEView extends React.Component { {getTitle(this.props)} - {this.props.toast.isVisible && } +