recoil-nexus
Advanced tools
Comparing version 0.1.2 to 0.1.3
{ | ||
"name": "recoil-nexus", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "A small Typescript package to access your Recoil atoms outside of React components.", | ||
@@ -5,0 +5,0 @@ "main": "build/RecoilNexus.js", |
@@ -43,18 +43,20 @@ # R E C O I L - N E X U S | ||
export default App; | ||
``` | ||
### 2. Use hooks to get/set values: keep in mind that the GET value will return a Promise. | ||
<br/> | ||
\ | ||
| Hook | Returns | | ||
| :------------- | :----------- | | ||
| `useRecoilNexus` | returns getter/setter tuple | | ||
| `useRecoilNexusValue` | returns getter only, which will return a promise | | ||
| `useRecoilNexusSetValue` | returns setter function | | ||
<br/> | ||
| `useRecoilNexus` | getter/setter tuple | | ||
| `useRecoilNexusValue` | getter only, which will return a promise | | ||
| `useRecoilNexusSetValue` | setter function | | ||
\ | ||
```tsx | ||
// Loading example | ||
import { loadingState } from '../atoms/loadingState' | ||
import { useRecoilNexus, useRecoilNexusValue, useRecoilNexusSetValue } from 'recoil-nexus' | ||
import { useRecoilNexus } from 'recoil-nexus' | ||
@@ -94,4 +96,4 @@ export default async function toggleLoading() { | ||
## Warning | ||
Using them on the top level of a file is fully functional, **however** it will trigger es-lint checker. | ||
## ESLint Warning | ||
Despite these hooks are fully functional, they **will trigger ESLint rules**. | ||
@@ -105,6 +107,13 @@ ``` | ||
``` | ||
React Hook "useRecoilNexus" is called in function "toggleLoading" which is | ||
neither a React function component or a custom React Hook function | ||
react-hooks/rules-of-hooks | ||
``` | ||
### To workaround this you can either: | ||
- import with an alias | ||
```tsx | ||
import { useRecoilNexus as _useNexus } from 'recoil-nexus' | ||
import { useRecoilNexus as üseRecoilNexus } from 'recoil-nexus' | ||
``` | ||
@@ -115,3 +124,3 @@ - or disable es-lint rule for the single line: | ||
``` | ||
- or disable the Hooks Rule for the whole file (not recommended): | ||
- or disable the Hooks Rule for the whole file (...not recommended): | ||
```tsx | ||
@@ -124,2 +133,1 @@ /* eslint-disable react-hooks/rules-of-hooks */ | ||
This is a Typescript port + enhancement of [VeepCream](https://github.com/VeepCream)'s [recoil-outside](https://www.npmjs.com/package/recoil-outside). | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12865
129