Skip to content
This repository has been archived by the owner on Jan 13, 2023. It is now read-only.

Commit

Permalink
fix(hooks): Fix #274 - Add eslint-plugin-react-hooks (#369 by @noname…
Browse files Browse the repository at this point in the history
…olsson)

[skip ci]
  • Loading branch information
nonameolsson committed Sep 24, 2020
1 parent fb03e55 commit d08a27b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
7 changes: 2 additions & 5 deletions boilerplate/app/components/switch/switch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,9 @@ export function Switch(props: SwitchProps) {
startAnimation(props.value)
setPreviousValue(props.value)
}
}, [props.value])
}, [previousValue, props.value, startAnimation])

const handlePress = React.useMemo(() => () => props.onToggle && props.onToggle(!props.value), [
props.onToggle,
props.value,
])
const handlePress = React.useMemo(() => () => props.onToggle && props.onToggle(!props.value), [props])

if (!timer) {
return null
Expand Down
8 changes: 4 additions & 4 deletions boilerplate/app/navigation/navigation-utilities.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, useEffect, useRef } from "react"
import React, { useCallback, useState, useEffect, useRef } from "react"
import { BackHandler } from "react-native"
import { PartialState, NavigationState, NavigationContainerRef } from "@react-navigation/native"

Expand Down Expand Up @@ -110,18 +110,18 @@ export function useNavigationPersistence(storage: any, persistenceKey: string) {
storage.save(persistenceKey, state)
}

const restoreState = async () => {
const restoreState = useCallback(async () => {
try {
const state = await storage.load(persistenceKey)
if (state) setInitialNavigationState(state)
} finally {
setIsRestoringNavigationState(false)
}
}
}, [persistenceKey, storage])

useEffect(() => {
if (isRestoringNavigationState) restoreState()
}, [isRestoringNavigationState])
}, [isRestoringNavigationState, restoreState])

return { onNavigationStateChange, restoreState, initialNavigationState }
}
1 change: 1 addition & 0 deletions boilerplate/app/services/reactotron/reactotron.ts.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ export class Reactotron {
if (this.config.useAsyncStorage) {
Tron.setAsyncStorageHandler(AsyncStorage)
}
// eslint-disable-next-line react-hooks/rules-of-hooks
Tron.useReactNative({
asyncStorage: this.config.useAsyncStorage ? undefined : false,
})
Expand Down
2 changes: 2 additions & 0 deletions boilerplate/package.json.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
"eslint-plugin-promise": "^4.0.1",
"eslint-plugin-react": "^7.12.4",
"eslint-plugin-react-native": "^3.6.0",
"eslint-plugin-react-hooks": "^4.1.0",
"eslint-plugin-standard": "^4.0.0",
"jest": "25.5.4",
<% if (props.useExpo) { -%>
Expand Down Expand Up @@ -163,6 +164,7 @@
"plugin:@typescript-eslint/recommended",
"plugin:react/recommended",
"plugin:react-native/all",
"plugin:react-hooks/recommended",
"standard"
],
"parserOptions": {
Expand Down

0 comments on commit d08a27b

Please sign in to comment.