Use React.useContext instead of Context.Consumer

This commit is contained in:
Amine Ben hammou
2019-07-11 18:40:15 +01:00
committed by M. Shull
parent a327d7f80a
commit a49a6a6a65

View File

@@ -8,7 +8,14 @@ function SelectImportMethod({
activeMethod, activeMethod,
onMethodChange, onMethodChange,
}) { }) {
const renderSelection = () => ( const { isNewUser } = React.useContext(ImportContext);
const badgeClasses = classNames(
'mailpoet_badge',
'mailpoet_badge_video',
{ mailpoet_badge_video_grey: !isNewUser }
);
return (
<>
<form className="mailpoet_import_selection_form"> <form className="mailpoet_import_selection_form">
<span className="mailpoet_import_heading">{MailPoet.I18n.t('methodSelectionHead')}</span> <span className="mailpoet_import_heading">{MailPoet.I18n.t('methodSelectionHead')}</span>
<label htmlFor="import-paste-method"> <label htmlFor="import-paste-method">
@@ -45,19 +52,6 @@ function SelectImportMethod({
{MailPoet.I18n.t('methodMailChimp')} {MailPoet.I18n.t('methodMailChimp')}
</label> </label>
</form> </form>
);
return (
<ImportContext.Consumer>
{({ isNewUser }) => {
const badgeClasses = classNames(
'mailpoet_badge',
'mailpoet_badge_video',
{ mailpoet_badge_video_grey: !isNewUser }
);
return (
<>
{renderSelection()}
<a <a
className={badgeClasses} className={badgeClasses}
href="https://kb.mailpoet.com/article/242-video-guide-importing-subscribers-using-a-csv-file" href="https://kb.mailpoet.com/article/242-video-guide-importing-subscribers-using-a-csv-file"
@@ -69,9 +63,6 @@ function SelectImportMethod({
</a> </a>
</> </>
); );
}}
</ImportContext.Consumer>
);
} }
SelectImportMethod.propTypes = { SelectImportMethod.propTypes = {