tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

ReportContentToast.jsx (1064B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
      3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 import React, { useEffect, useRef } from "react";
      6 
      7 function ReportContentToast({ onDismissClick, onAnimationEnd }) {
      8  const mozMessageBarRef = useRef(null);
      9 
     10  useEffect(() => {
     11    const { current: mozMessageBarElement } = mozMessageBarRef;
     12 
     13    mozMessageBarElement.addEventListener(
     14      "message-bar:user-dismissed",
     15      onDismissClick,
     16      {
     17        once: true,
     18      }
     19    );
     20 
     21    return () => {
     22      mozMessageBarElement.removeEventListener(
     23        "message-bar:user-dismissed",
     24        onDismissClick
     25      );
     26    };
     27  }, [onDismissClick]);
     28 
     29  return (
     30    <moz-message-bar
     31      type="success"
     32      class="notification-feed-item"
     33      dismissable={true}
     34      data-l10n-id="newtab-toast-thanks-for-reporting"
     35      ref={mozMessageBarRef}
     36      onAnimationEnd={onAnimationEnd}
     37    ></moz-message-bar>
     38  );
     39 }
     40 
     41 export { ReportContentToast };