An open API service indexing awesome lists of open source software.

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

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;
```