john-state-library
v1.0.1
Published
A custom state management library for React Native Expo.
Downloads
3
Maintainers
Readme
John State Library
John State Library is a simple and lightweight state management library for React Native Expo applications. It provides a convenient way to manage global state using React's context API and custom hooks.
Installation
You can install John State Library via npm or yarn:
npm install john-state-library
or
bash
Copy code
yarn add john-state-library
Usage
1. Import JohnProvider and useJohnState
javascript
Copy code
import React from 'react';
import { JohnProvider, useJohnState } from 'john-state-library';
// Your components using the state
2. Wrap your application with JohnProvider
Wrap your application with the JohnProvider component to provide access to the global state.
javascript
Copy code
const App = () => {
return (
<JohnProvider>
{/* Your app components */}
</JohnProvider>
);
};
export default App;
3. Use useJohnState hook to access and update the state
javascript
Copy code
const ExampleComponent = () => {
const { state, setState } = useJohnState();
return (
<div>
<p>State: {state}</p>
<input
type="text"
value={state}
onChange={(e) => setState(e.target.value)}
/>
</div>
);
};