// @flow import { SHARE_DOMAIN_URL } from 'config'; import React from 'react'; import { FormField } from 'component/common/form'; const DEBOUNCE_TEXT_INPUT_MS = 500; type Props = { customShareUrlEnabled: boolean, customShareUrl: string, setCustomShareUrlEnabled: (boolean) => void, setCustomShareUrl: (string) => void, }; function SettingShareUrl(props: Props) { const { customShareUrlEnabled, customShareUrl, setCustomShareUrlEnabled, setCustomShareUrl } = props; const [url, setUrl] = React.useState(customShareUrl); React.useEffect(() => { const timer = setTimeout(() => { if (url !== customShareUrl) { setCustomShareUrl(url); } }, DEBOUNCE_TEXT_INPUT_MS); return () => clearTimeout(timer); }, [url, customShareUrl, customShareUrlEnabled, setCustomShareUrl]); return ( { if (e.target.checked) { setCustomShareUrlEnabled(false); } }} /> { if (e.target.checked) { setCustomShareUrlEnabled(true); } }} /> {customShareUrlEnabled && (
setUrl(e.target.value)} />
)}
); } export default SettingShareUrl;