Skip to content

Fixes and cleaning #29

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 6 commits into from
Aug 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
13 changes: 12 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
.idea/*
# VSCode
.vscode/
jsconfig.json

# IntelliJ/Webstorm
.idea

# OS X
.DS_Store

# NodeJS
npm-debug.log
node_modules
yarn-error.log
8 changes: 8 additions & 0 deletions .release-it.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"npm": {
"publish": true
},
"github": {
"release": true
}
}
26 changes: 2 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ yarn add react-native-hooks
- [useCameraRoll](https://github.com/react-native-community/react-native-hooks#usecameraroll)
- [useClipboard](https://github.com/react-native-community/react-native-hooks#useclipboard)
- [useDimensions](https://github.com/react-native-community/react-native-hooks#usedimensions)
- [useGeolocation](https://github.com/react-native-community/react-native-hooks#usegeolocation)
- [useNetInfo](https://github.com/react-native-community/react-native-hooks#usenetinfo)
- [useKeyboard](https://github.com/react-native-community/react-native-hooks#usekeyboard)
- [useInteractionManager](https://github.com/react-native-community/react-native-hooks#useinteractionmanager)
- [useDeviceOrientation](https://github.com/react-native-community/react-native-hooks#usedeviceorientation)
Expand Down Expand Up @@ -81,35 +79,15 @@ import { useDimensions } from 'react-native-hooks'
const dimensions = useDimensions()
```

### `useGeolocation`

```js
import { useGeolocation } from 'react-native-hooks'

const [position, stopObserving, setRNConfiguration] = useGeolocation()

console.log('latitude: ', position.coords.latitude)
```

### `useNetInfo`

```js
import { useNetInfo } from 'react-native-hooks'

const netInfo = useNetInfo()

console.log('netInfo type: ', netInfo.type)
```

### `useKeyboard`

```js
import { useKeyboard } from 'react-native-hooks'

const keyboard = useKeyboard()

console.log('keyboard show: ', keyboard.show)
console.log('keyboard height: ', keyboard.height)
console.log('keyboard show: ', keyboard.isKeyboardShow)
console.log('keyboard height: ', keyboard.keyboardHeight)
```

### `useInteractionManager`
Expand Down
4 changes: 0 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import useAppState from './lib/useAppState'
import useCameraRoll from './lib/useCameraRoll'
import useClipboard from './lib/useClipboard'
import useAccessibilityInfo from './lib/useAccessibilityInfo'
import useGeolocation from './lib/useGeolocation'
import useNetInfo from './lib/useNetInfo'
import useKeyboard from './lib/useKeyboard'
import useInteractionManager from './lib/useInteractionManager'
import useDeviceOrientation from './lib/useDeviceOrientation'
Expand All @@ -15,8 +13,6 @@ export {
useCameraRoll,
useClipboard,
useAccessibilityInfo,
useGeolocation,
useNetInfo,
useKeyboard,
useInteractionManager,
useDeviceOrientation,
Expand Down
50 changes: 0 additions & 50 deletions lib/useGeolocation.js

This file was deleted.

20 changes: 10 additions & 10 deletions lib/useKeyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,33 @@ import { Keyboard } from 'react-native'
export default () => {
const [keyboard, setKeyboard] = useState({})

keyboardWillShow = e => {
function keyboardDidShow(e) {
setKeyboard({
isKeyboardShow: true,
keyboardHeight: e.endCoordinates.height
})
}

keyboardWillHide = e => {
function keyboardDidHide(e) {
setKeyboard({
isKeyboardShow: false,
keyboardHeight: e.endCoordinates.height
})
}

useEffect(() => {
this.keyboardWillShowListener = Keyboard.addListener(
'keyboardWillShow',
keyboardWillShow
this.keyboardDidShowListener = Keyboard.addListener(
'keyboardDidShow',
keyboardDidShow
)
this.keyboardWillHideListener = Keyboard.addListener(
'keyboardWillHide',
keyboardWillHide
this.keyboardDidHideListener = Keyboard.addListener(
'keyboardDidHide',
keyboardDidHide
)

return () => {
this.keyboardWillShowListener.remove()
this.keyboardWillHideListener.remove()
this.keyboardDidShowListener.remove()
this.keyboardDidHideListener.remove()
}
}, [])
return keyboard
Expand Down
30 changes: 0 additions & 30 deletions lib/useNetInfo.js

This file was deleted.

13 changes: 9 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
{
"name": "react-native-hooks",
"version": "0.0.7",
"version": "0.0.8",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "echo \"Error: no test specified\" && exit 1",
"release": "release-it"
},
"author": "Nader Dabit",
"license": "ISC",
"dependencies": {
"react": "^16.8.3"
"peerDependencies": {
"react": ">=16.8.0",
"react-native": ">=0.59"
},
"devDependencies": {
"release-it": "^12.3.5"
}
}
Loading