recoil-nexus
Advanced tools
Comparing version 0.1.3 to 0.1.4
{ | ||
"name": "recoil-nexus", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "A small Typescript package to access your Recoil atoms outside of React components.", | ||
@@ -5,0 +5,0 @@ "main": "build/RecoilNexus.js", |
@@ -47,11 +47,8 @@ # R E C O I L - N E X U S | ||
\ | ||
| Hook | Returns | | ||
| :------------- | :----------- | | ||
| `useRecoilNexus` | getter/setter tuple | | ||
| `useRecoilNexusValue` | getter only, which will return a promise | | ||
| `useRecoilNexusSetValue` | setter function | | ||
| `getRecoil` | getter function, returns a promise | | ||
| `setRecoil` | setter function | | ||
\ | ||
@@ -61,10 +58,9 @@ ```tsx | ||
import { loadingState } from '../atoms/loadingState' | ||
import { useRecoilNexus } from 'recoil-nexus' | ||
import { getRecoil, setRecoil } from 'recoil-nexus' | ||
export default async function toggleLoading() { | ||
const [getLoading, setLoading] = useRecoilNexus(loadingState) | ||
const loading = await getLoading() | ||
const loading = await getRecoil(loadingState) | ||
setLoading(!loading) | ||
setRecoil(loadingState, !loading) | ||
@@ -76,4 +72,4 @@ } | ||
//Loader | ||
import React from 'react' | ||
import { useRecoilNexus } from 'recoil-nexus' | ||
import React from "react" | ||
import { useRecoilValue } from "recoil" | ||
@@ -97,33 +93,2 @@ export default function Loader() { | ||
``` | ||
## ESLint Warning | ||
Despite these hooks are fully functional, they **will trigger ESLint rules**. | ||
``` | ||
React Hook "useRecoilNexus" cannot be called at the top level. | ||
React Hooks must be called in a React function component or a custom React Hook function | ||
react-hooks/rules-of-hooks | ||
``` | ||
``` | ||
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 üseRecoilNexus } from 'recoil-nexus' | ||
``` | ||
- or disable es-lint rule for the single line: | ||
```tsx | ||
// eslint-disable-next-line react-hooks/rules-of-hooks | ||
``` | ||
- or disable the Hooks Rule for the whole file (...not recommended): | ||
```tsx | ||
/* eslint-disable react-hooks/rules-of-hooks */ | ||
``` | ||
_____________ | ||
@@ -130,0 +95,0 @@ ### Credits |
Sorry, the diff of this file is not supported yet
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
11645
175
94