https://github.com/rnkids/react-hooks-context
simple react context wrapper with hooks
https://github.com/rnkids/react-hooks-context
react-context react-hooks
Last synced: 9 months ago
JSON representation
simple react context wrapper with hooks
- Host: GitHub
- URL: https://github.com/rnkids/react-hooks-context
- Owner: rnkids
- License: mit
- Created: 2019-07-06T14:11:35.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-07-06T15:23:54.000Z (almost 7 years ago)
- Last Synced: 2025-08-08T18:59:56.289Z (10 months ago)
- Topics: react-context, react-hooks
- Language: JavaScript
- Size: 3.91 KB
- Stars: 3
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# react-hooks-context
simple react context wrapper with hooks
# usage
```
npm i -S @lequysang/react-hooks-context
```
Wrap your Root app and give your value
```jsx
import React, { useState } from 'react'
import { ContextProvider } from '@lequysang/react-hooks-context'
const App = () => {
const [state, setState] = useState(0);
const action = () => {
console.log('your action');
}
return (
Your React Root
// Your React Native Root
);
};
export default App;
```
Get value back in your View
```jsx
import { useValue } from '@lequysang/react-hooks-context';
const YourView = () => {
const { state, action } = useValue();
return (
{state}
)
}
export default YourView;
```