import { useEffect, useState } from "react"; import { FeatureId } from "../constants"; import { useViewedState } from "../hooks"; import { getNewsletterSubscription, toggleNewsletterSubscription, } from "../plus/common/api"; import { Spinner } from "../ui/atoms/spinner"; import { Switch } from "../ui/atoms/switch"; export default function Newsletter() { const [loading, setLoading] = useState(true); const [enabled, setEnabled] = useState(null); useEffect(() => { (async () => { setEnabled(await getNewsletterSubscription()); setLoading(false); })(); }, []); const { isViewed, setViewed } = useViewedState(); if (!isViewed(FeatureId.PLUS_NEWSLETTER)) { setViewed(FeatureId.PLUS_NEWSLETTER); } return (

Stay updated

  • MDN Plus Newsletter (Deprecated)

    We're decommissioning our MDN Plus newsletter. {enabled ? ( <> {" "} If you unsubscribe, you cannot subscribe again.
    We will automatically unsubscribe you and purge all related data soon. ) : ( <> )}
    {loading ? ( ) : enabled ? ( { setLoading(true); setEnabled( await toggleNewsletterSubscription( Boolean(e.target.checked) ) ); setLoading(false); }} > ) : ( <> )}
); }