Skip to content

[chore] Use Community's eslint config, change info about hooks API #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
302 changes: 12 additions & 290 deletions .eslintrc

Large diffs are not rendered by default.

19 changes: 0 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,25 +54,6 @@ getData = async () => {

```

### useAsyncStorage hook

React hooks (introduced in 16.8) allow you to use state and async requests without writing a class. For more info on hooks and how to use them, see [hooks documentation](https://reactjs.org/docs/hooks-intro.html) or the [hooks example](docs/Hooks.md) in this repo.

`useAsyncStorage` has no hard-coded dependencies in react hooks, it is just a convenience wrapper around `AsyncStorage`.

```js
import { useAsyncStorage } from '@react-native-community/async-storage';
```

```jsx
const {
getItem,
setItem,
mergeItem,
removeItem
} = useAsyncStorage('@storage_key');
```

See docs for [api and more examples.](docs/API.md)

## Contribution
Expand Down
3 changes: 2 additions & 1 deletion docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,8 @@ static flushGetRequests(): void

## `useAsyncStorage`

Uses the new [hooks api](https://reactjs.org/docs/hooks-intro.html) to give you convenience functions so you can get, set, merge and delete a value for a given key from Async Storage.
**Note**: A hooks-like interface that we're experimenting with. This will change in the nearest future to fully leverage Hooks API, so feel free to [follow this discussion to learn more](https://github.com/react-native-community/react-native-async-storage/issues/32).


The `useAsyncStorage` returns an object that exposes all methods that allow you to interact with the stored value.

Expand Down
1 change: 0 additions & 1 deletion example/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
Text,
TouchableOpacity,
View,
ScrollView,
Keyboard,
Button,
} from 'react-native';
Expand Down
2 changes: 1 addition & 1 deletion lib/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ export function useAsyncStorage(key: string): AsyncStorageHook {
mergeItem: (...args) => AsyncStorage.mergeItem(key, ...args),
removeItem: (...args) => AsyncStorage.removeItem(key, ...args),
};
}
}
12 changes: 1 addition & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,16 @@
},
"devDependencies": {
"@babel/core": "7.0.0",
"@react-native-community/eslint-config": "0.0.2",
"@semantic-release/git": "7.0.8",
"babel-core": "7.0.0-bridge.0",
"babel-eslint": "9.0.0",
"babel-jest": "24.1.0",
"babel-plugin-module-resolver": "3.1.3",
"detox": "10.0.7",
"eslint": "5.1.0",
"eslint-config-fb-strict": "22.1.0",
"eslint-config-fbjs": "2.0.1",
"eslint-plugin-eslint-comments": "3.0.1",
"eslint-plugin-flowtype": "2.43.0",
"eslint-plugin-jest": "21.8.0",
"eslint-plugin-prettier": "2.6.0",
"eslint-plugin-react": "7.8.2",
"eslint-plugin-react-hooks": "1.0.1",
"eslint-plugin-react-native": "3.5.0",
"flow-bin": "0.86.0",
"jest": "24.1.0",
"metro-react-native-babel-preset": "0.51.1",
"prettier": "1.16.4",
"react": "16.6.3",
"react-native": "0.58.4",
"react-test-renderer": "16.6.3",
Expand Down
65 changes: 34 additions & 31 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,21 @@
universal-user-agent "^2.0.0"
url-template "^2.0.8"

"@react-native-community/eslint-config@^0.0.2":
version "0.0.2"
resolved "https://registry.yarnpkg.com/@react-native-community/eslint-config/-/eslint-config-0.0.2.tgz#042224762e00ef06b45693a14be78ebda5fb7def"
integrity sha512-oKtMR046Ptfjvzd67MPm7Q8a5H8MeMsKB7E5bKgcMoybdZBmrsqo3Fn49FCKwc6yHd4KUkTyQihE4Fgk9jaanA==
dependencies:
babel-eslint "9.0.0"
eslint-plugin-eslint-comments "^3.0.1"
eslint-plugin-flowtype "2.43.0"
eslint-plugin-jest "21.8.0"
eslint-plugin-prettier "2.6.0"
eslint-plugin-react "7.8.2"
eslint-plugin-react-hooks "^1.0.1"
eslint-plugin-react-native "3.5.0"
prettier "1.13.6"

"@semantic-release/commit-analyzer@^6.1.0":
version "6.1.0"
resolved "https://registry.yarnpkg.com/@semantic-release/commit-analyzer/-/commit-analyzer-6.1.0.tgz#32bbe3c23da86e23edf072fbb276fa2f383fcb17"
Expand Down Expand Up @@ -2579,30 +2594,13 @@ escodegen@^1.9.1:
optionalDependencies:
source-map "~0.6.1"

eslint-config-fb-strict@22.1.0:
version "22.1.0"
resolved "https://registry.yarnpkg.com/eslint-config-fb-strict/-/eslint-config-fb-strict-22.1.0.tgz#6a81785d45748d6c753442772b84da0aca13c45f"
integrity sha512-UFJeCwl7Zg7s3d90PjedcNbjpMBzyojTiF9H6lEJMp/XU8oSlSDzk1UFOz41YqdG2BFyg5xsRbQngquJkTxrxg==
dependencies:
eslint-config-fbjs "^2.0.1"

eslint-config-fbjs@2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/eslint-config-fbjs/-/eslint-config-fbjs-2.0.1.tgz#395896fd740e0e28dc1c2072e3bc982e88247df5"
integrity sha512-nZ/JByixNK/8epeQqmrtNCYYMXCjHoPkJwHaHg4aZyZlS62YLttDSWYE6ISGl070V+o6dkFbDALceWaO3Po+Sw==

eslint-config-fbjs@^2.0.1:
version "2.1.0"
resolved "https://registry.yarnpkg.com/eslint-config-fbjs/-/eslint-config-fbjs-2.1.0.tgz#bfe4f8c2d2282bfe515359553905d830e3a5d12f"
integrity sha512-wh7Lveo51V3/SUydWtR2VEU8wNfSHt5V7YzIUKTRkHF3kvkCwFtM6Jgsn+xBNkjxZGpfWgNJN/drk1LLx64Dww==

eslint-plugin-eslint-comments@3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-eslint-comments/-/eslint-plugin-eslint-comments-3.0.1.tgz#baafb713584c0de7ee588710720e580bcc28cfbb"
integrity sha512-7zU6gCulKVmfG3AZdnvDxzfHaGdvkA8tsLiKbneeI/TlVaulJsRzOyMCctH9QTobKVJ6LIsiJbrkSKkgcFLHxw==
eslint-plugin-eslint-comments@^3.0.1:
version "3.1.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-eslint-comments/-/eslint-plugin-eslint-comments-3.1.1.tgz#32ff0afba8a48e17073817e6d03fbc5622f735b7"
integrity sha512-GZDKhOFqJLKlaABX+kdoLskcTINMrVOWxGca54KcFb1QCPd0CLmqgAMRxkkUfGSmN+5NJUMGh7NGccIMcWPSfQ==
dependencies:
escape-string-regexp "^1.0.5"
ignore "^3.3.8"
ignore "^5.0.5"

eslint-plugin-flowtype@2.43.0:
version "2.43.0"
Expand All @@ -2624,10 +2622,10 @@ eslint-plugin-prettier@2.6.0:
fast-diff "^1.1.1"
jest-docblock "^21.0.0"

eslint-plugin-react-hooks@1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-1.0.1.tgz#76b6fb4edafab02eab0090078977687157605dd9"
integrity sha512-yNhvY7EFBp0mq0Bt8BHoS57GwJ4e1qSYdvDFSfPnjmiSmyGUfQFQGcQs4K0JQFDGopWkURWq58psbUJIhWZ2Kg==
eslint-plugin-react-hooks@^1.0.1:
version "1.5.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-1.5.0.tgz#cdd958cfff55bd5fa4f84db90d1490fb5ca4ae2b"
integrity sha512-iwDuWR2ReRgvJsNm8fXPtTKdg78IVQF8I4+am3ntztPf/+nPnWZfArFu6aXpaC75/iCYRrkqI8nPCYkxJstmpA==

eslint-plugin-react-native-globals@^0.1.1:
version "0.1.2"
Expand Down Expand Up @@ -3699,7 +3697,7 @@ ignore-walk@^3.0.1:
dependencies:
minimatch "^3.0.4"

ignore@^3.3.3, ignore@^3.3.8:
ignore@^3.3.3:
version "3.3.10"
resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.3.10.tgz#0a97fb876986e8081c631160f8f9f389157f0043"
integrity sha512-Pgs951kaMm5GXP7MOvxERINe3gsaVjUWFm+UZPSq9xYriQAksyhg0csnS0KXSNRD5NmNdapXEpjxG49+AKh/ug==
Expand All @@ -3709,6 +3707,11 @@ ignore@^4.0.3:
resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc"
integrity sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==

ignore@^5.0.5:
version "5.0.5"
resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.0.5.tgz#c663c548d6ce186fb33616a8ccb5d46e56bdbbf9"
integrity sha512-kOC8IUb8HSDMVcYrDVezCxpJkzSQWTAzf3olpKM6o9rM5zpojx23O0Fl8Wr4+qJ6ZbPEHqf1fdwev/DS7v7pmA==

image-size@^0.6.0:
version "0.6.3"
resolved "https://registry.yarnpkg.com/image-size/-/image-size-0.6.3.tgz#e7e5c65bb534bd7cdcedd6cb5166272a85f75fb2"
Expand Down Expand Up @@ -6748,10 +6751,10 @@ preserve@^0.2.0:
resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b"
integrity sha1-gV7R9uvGWSb4ZbMQwHE7yzMVzks=

prettier@1.16.4:
version "1.16.4"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.16.4.tgz#73e37e73e018ad2db9c76742e2647e21790c9717"
integrity sha512-ZzWuos7TI5CKUeQAtFd6Zhm2s6EpAD/ZLApIhsF9pRvRtM1RFo61dM/4MSRUA0SuLugA/zgrZD8m0BaY46Og7g==
prettier@1.13.6:
version "1.13.6"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.13.6.tgz#00ae0b777ad92f81a9e7a1df2f0470b6dab0cb44"
integrity sha512-p5eqCNiohWZN++7aJXUVj0JgLqHCPLf9GLIcLBHGNWs4Y9FJOPs6+KNO2WT0udJIQJTbeZFrJkjzjcb8fkAYYQ==

pretty-format@24.0.0-alpha.6:
version "24.0.0-alpha.6"
Expand Down