diff --git a/packages/pl-fe/src/features/share/index.tsx b/packages/pl-fe/src/features/share/index.tsx index 335a1a0fd..d3d51552c 100644 --- a/packages/pl-fe/src/features/share/index.tsx +++ b/packages/pl-fe/src/features/share/index.tsx @@ -1,30 +1,34 @@ -import React from 'react'; -import { Redirect, useLocation } from 'react-router-dom'; +import React, { useEffect } from 'react'; +import { useHistory, useLocation } from 'react-router-dom'; import { openComposeWithText } from 'pl-fe/actions/compose'; import { useAppDispatch } from 'pl-fe/hooks/use-app-dispatch'; -const Share = () => { +const Share: React.FC = () => { const dispatch = useAppDispatch(); + const history = useHistory(); const { search } = useLocation(); - const params = new URLSearchParams(search); - - const text = [ - params.get('title'), - params.get('text'), - params.get('url'), - ] - .filter(v => v) - .join('\n\n'); - - if (text) { - dispatch(openComposeWithText('compose-modal', text)); - } - - return ( - - ); + + useEffect(() => { + const params = new URLSearchParams(search); + + const text = [ + params.get('title'), + params.get('text'), + params.get('url'), + ] + .filter(v => v) + .join('\n\n'); + + if (text) { + dispatch(openComposeWithText('compose-modal', text)); + } + + history.replace('/'); + }); + + return null; }; export { Share as default };