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

Fix #274 - Add eslint-plugin-react-hooks #369

Merged
merged 2 commits into from
Sep 24, 2020
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
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 @@ -79,6 +79,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 @@ -158,6 +159,7 @@
"plugin:@typescript-eslint/recommended",
"plugin:react/recommended",
"plugin:react-native/all",
"plugin:react-hooks/recommended",
"standard"
],
"parserOptions": {
Expand Down