<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>yum_fishing</author_name>
  <author_url>https://blog.hatena.ne.jp/yum_fishing/</author_url>
  <blog_title>iOSエンジニアのつぶやき</blog_title>
  <blog_url>https://yamato8010.hatenablog.com/</blog_url>
  <categories>
    <anon>React</anon>
    <anon>TypeScript</anon>
  </categories>
  <description>結論 下記のようにして、全体の要素のmousedownイベントを監視して、そのイベントの中のtargetRefに関するイベントのみ除外することで、特定の要素以外の場所がタップされたことを検知することができます👀 const targetRef: React.RefObject&lt;HTMLDivElement&gt; = React.createRef() useEffect(() =&gt; { const handleClickOutside = (event: MouseEvent) =&gt; { if ( targetRef.current &amp;&amp; !targetRef.current.contains(e…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fyamato8010.hatenablog.com%2Fentry%2F2021%2F06%2F21%2F083000&quot; title=&quot;【React】特定のコンポーネントの外側のタップを検出する - iOSエンジニアのつぶやき&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url>https://cdn.user.blog.st-hatena.com/default_entry_og_image/156070317/1620294104599893</image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2021-06-21 08:30:00</published>
  <title>【React】特定のコンポーネントの外側のタップを検出する</title>
  <type>rich</type>
  <url>https://yamato8010.hatenablog.com/entry/2021/06/21/083000</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
