fix: disable share feature on component unmount (#1048)

* fix: disable share feature on component unmount

* chore: make sure useEffect run only once

Co-authored-by: Leangseu Kim <lkim@edx.org>
This commit is contained in:
Ben Warzeski
2023-01-20 09:07:18 -05:00
committed by GitHub
parent b082f3ed19
commit 0c74bb5106

View File

@@ -1,3 +1,4 @@
import React from 'react';
import { PropTypes } from 'prop-types';
import { useIntl } from '@edx/frontend-platform/i18n';
import { TwitterShareButton, TwitterIcon } from 'react-share';
@@ -19,6 +20,10 @@ const ShareTwitterIcon = () => (
function ShareButton({ url }) {
const { formatMessage } = useIntl();
React.useEffect(() => () => {
window.expSocialShareEnabled = false;
}, []);
const twitterUrl = stringifyUrl({
url,
query: {