react-native-screenshot-aware
Version:
React Native module for real-time screenshot detection on Android and iOS
59 lines • 1.68 kB
TypeScript
/**
* A React hook that listens for screenshot events and triggers a callback when a screenshot is taken.
*
* @param {() => void} callback - The function to be called when a screenshot event occurs.
*
* @example
* ```jsx
* import { useScreenshotAware } from 'react-native-screenshot-aware';
*
* function MyComponent() {
* useScreenshotAware(() => {
* console.log('A screenshot was taken!');
* });
*
* return <View>...</View>;
* }
* ```
*/
export declare const useScreenshotAware: (callback: () => void) => void;
/**
* Module object for managing screenshot event listeners.
* Useful for class components or non-React contexts.
*
* @example
* ```jsx
* import ScreenshotAware from 'react-native-screenshot-aware';
*
* class MyComponent extends React.Component {
* componentDidMount() {
* this.subscription = ScreenshotAware.addListener(() => {
* console.log('A screenshot was taken!');
* });
* }
*
* componentWillUnmount() {
* this.subscription.remove();
* }
*
* render() {
* return <View>...</View>;
* }
* }
* ```
*/
declare const ScreenshotAware: {
/**
* Adds a listener for screenshot events.
*
* @param {() => void} callback - The function to be called when a screenshot event occurs.
* @returns {import('react-native').EmitterSubscription} A subscription object that can be used to remove the listener.
*/
addListener: (callback: () => void) => import("react-native").EmitterSubscription;
/**
* Removes all listeners for screenshot events.
*/
removeAllListeners: () => void;
};
export default ScreenshotAware;
//# sourceMappingURL=index.d.ts.map