Package Exports
- @secret-knock/react-native
- @secret-knock/react-native/lib/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@secret-knock/react-native) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
๐คซโ๐ช Secret knock
A hook for handling secret knocks in React Native.
This also exists for React.
Install
// ๐งถ Yarn
yarn add @secret-knock/react-native
// ๐ฆ NPM
npm install --save @secret-knock/react-nativeExample
import React from "react";
import { Pressable, Text, View } from "react-native";
import { useSecretKnock } from "@secret-knock/react-native";
export const HiddenSecret = () => {
// press, press, press, long press,
// pause, press, press, press,
// long press, long press, long press
const secretKnockSequence = "...-/...---";
const {
unlocked,
progress,
Knocker,
reset,
} = useSecretKnock(secretKnockSequence);
return (
<View>
<Knocker>
<Text>Knock me!</Text>
</Knocker>
<View style={{ backgroundColor: "#ccc" }}>
<View
style={{
height: 10,
width: `${progress * 100}%`,
backgroundColor: unlocked ? "lime" : "red",
}}
/>
</View>
{unlocked && (
<Pressable onPress={reset}>
<Text>Reset</Text>
</Pressable>
)}
</View>
);
};