Skip to content

Commit 2be886e

Browse files
author
Dabit
committed
updated function syntax
1 parent 2e4a69c commit 2be886e

7 files changed

+16
-16
lines changed

lib/useAccessibilityInfo.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useEffect, useState } from 'react'
22
import { AccessibilityInfo } from 'react-native'
33

4-
export default () => {
4+
export default function useAccessibilityInfo() {
55
const [screenReaderEnabled, updateScreenReaderInfo] = useState(null)
66

77

lib/useAppState.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import React, { useEffect, useState } from 'react'
22
import { AppState } from 'react-native'
33

4-
// https://github.com/facebook/react-native/issues/18836
5-
export default () => {
4+
export default function useAppState() {
65
const currentState = AppState.currentState
76
const [appState, setAppState] = useState(currentState)
87

@@ -16,7 +15,7 @@ export default () => {
1615
return () => {
1716
AppState.removeEventListener('change', onChange)
1817
}
19-
},[])
18+
})
2019

2120
return appState
2221
}

lib/useBackHandler.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import React, { useEffect, useState } from 'react'
1+
import React, { useEffect } from 'react'
22
import { BackHandler } from 'react-native'
33

4-
export default (handler) => {
4+
export default function useBackHandler(handler) {
55
useEffect(() => {
66
BackHandler.addEventListener('hardwareBackPress', handler)
77

lib/useCameraRoll.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const defaultConfig = {
1717
groupTypes: 'All'
1818
}
1919

20-
export default function() {
20+
export default function useCameraRoll() {
2121
const [photos, setPhotos] = useState(initialState)
2222

2323
async function getPhotos(config = defaultConfig) {

lib/useClipboard.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import React, { useEffect, useState } from 'react'
22
import { Clipboard } from 'react-native'
33

4-
export default () => {
4+
export default function useClipBoard() {
55
const [data, updateClipboardData] = useState('')
66

7+
async function updateClipboard() {
8+
const content = await Clipboard.getString()
9+
updateClipboardData(content);
10+
}
11+
712
useEffect(() => {
8-
async function updateClipboard() {
9-
const content = await Clipboard.getString()
10-
updateClipboardData(content);
11-
}
1213
updateClipboard()
1314
}, [])
1415

lib/useDeviceOrientation.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import { Dimensions } from 'react-native';
33

44
const screen = Dimensions.get('screen');
55

6-
const isOrientationPortrait = ({ width, height }) => height >= width;
7-
const isOrientationLandscape = ({ width, height }) => width >= height;
6+
export default function() {
7+
isOrientationPortrait = ({ width, height }) => height >= width;
8+
isOrientationLandscape = ({ width, height }) => width >= height;
89

9-
export default () => {
1010
const [orientation, setOrientation] = useState({
1111
portrait: isOrientationPortrait(screen),
1212
landscape: isOrientationLandscape(screen)

lib/useDimensions.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Dimensions } from 'react-native'
44
const window = Dimensions.get('window')
55
const screen = Dimensions.get('screen')
66

7-
export default () => {
7+
export default function useDimensions() {
88
const [dimensions, setDimensions] = useState({
99
window, screen
1010
})

0 commit comments

Comments
 (0)