npm.io
1.0.16 • Published 5d ago

react-native-contains

Licence
MIT
Version
1.0.16
Deps
0
Size
19 kB
Vulns
0
Weekly
0
Stars
1

react-native-contains

Check whether one element or native view contains another element or native tag.

Install

npm install react react-native react-native-contains

Use

import { useRef } from "react";
import { Pressable, View } from "react-native";
import contains from "react-native-contains";

function Component() {
  const ref = useRef(null);
  return (
    <View>
      <View ref={ref}>
        <Pressable onPress={(event) => {
          console.log(contains(ref.current, event.target)); // true
        }} />
      </View>
      <Pressable onPress={(event) => {
        console.log(contains(ref.current, event.target)); // false
      }} />
    </View>
  );
}

Documentation

API Docs

Keywords