A React Native hook that handles enabling a 'developer mode' in response to a certain number of taps from the user.
npm install @brown-ccv/rn-use-dev-modeA "developer mode" state manager for enabling developer-facing UI during production in React web and native applications.
The package provides a React Context object that keeps track of a count state variable, with an exposed increment function. When the count reaches a provided maximum, the user is asked for a PIN; if that is correct, developer mode is enabled. It's up to the developer how to handle calling the increment function.
``sh`
npm install @brown-ccv/rn-use-dev-mode
or
`sh`
yarn add @brown-ccv/rn-use-dev-mode
or
`sh`
pnpm add @brown-ccv/rn-use-dev-mode
See the documentation for details on exported functions.
In the root component of your project, import the DeveloperModeProvider component and
wrap it around all parts of the application that need access to the context object:
`js
import { DeveloperModeProvider } from "@brown-ccv/rn-use-dev-mode";
export function SomeRootComponent() {
// ...
return (
<>
>
);
}
`
In child components, import the useDeveloperMode hook:
`js
import { useDeveloperMode } from "@brown-ccv/rn-use-dev-mode";
export function SomeChild() {
// ...
const { devMode, count, incrementCount } = useDeveloperMode();
// ...
return (
<>
Count: {count}
{devMode ? "Dev mode is enabled!" : "Dev mode is disabled"}
Documentation
The developer mode
Context object has the following structure:-
devMode: a boolean, whether or not developer mode is enabled.
- count: a number; when count reaches a given value, the user is prompted for the PIN.
- incrementCount: a function that, when called, increments count by one.To access the
Context, the package exports two functions:$3
A component which returns a React
Context.Provider and accepts any valid React children.#### Props
-
maxCount: When count reaches this value, developer mode is enabled.#### Returns
All children of this component can call
useDeveloperMode to access the developer mode Context object.$3
A hook that returns the current
value of the Context`.See the contributing guide to learn how to contribute to the repository and the development workflow.
MIT
---
Made with create-react-native-library