Skip to content

Commit 1ed4cd3

Browse files
authored
fix: cycle dependencies (#563)
## 📜 Description Fixed cycle dependencies in the code. ## 💡 Motivation and Context Cycle dependencies may lead to unpredictable results especially if you have many of them. To fix them I used `eslint` rule - it's quite effective and we don't need to change CI pipelines etc. Plus we can monitor such cycles contioniously! Closes #562 ## 📢 Changelog <!-- High level overview of important changes --> <!-- For example: fixed status bar manipulation; added new types declarations; --> <!-- If your changes don't affect one of platform/language below - then remove this platform/language --> ### JS - reorganized imports to avoid cycle deps; - added new eslint rule usage. ## 🤔 How Has This Been Tested? Tested on e2e tests on CI 🙂 ## 📝 Checklist - [x] CI successfully passed - [x] I added new mocks and corresponding unit-tests if library API was changed
1 parent 34493cd commit 1ed4cd3

File tree

7 files changed

+9
-14
lines changed

7 files changed

+9
-14
lines changed

.eslintrc.cjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ module.exports = {
108108
"newlines-between": "always",
109109
},
110110
],
111+
"import/no-cycle": ["error", { maxDepth: "∞" }],
111112
// jest
112113
"jest/expect-expect": [
113114
"warn",

src/components/KeyboardAvoidingView/hooks.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import { useSharedValue } from "react-native-reanimated";
22

3-
import {
4-
useKeyboardContext,
5-
useKeyboardHandler,
6-
} from "react-native-keyboard-controller";
3+
import { useKeyboardContext } from "../../context";
4+
import { useKeyboardHandler } from "../../hooks";
75

86
export const useKeyboardAnimation = () => {
97
const { reanimated } = useKeyboardContext();

src/components/KeyboardAvoidingView/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import Reanimated, {
88
useSharedValue,
99
} from "react-native-reanimated";
1010

11-
import { useWindowDimensions } from "react-native-keyboard-controller";
11+
import { useWindowDimensions } from "../../hooks";
1212

1313
import { useKeyboardAnimation } from "./hooks";
1414

src/components/KeyboardAwareScrollView/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
useFocusedInputHandler,
1515
useReanimatedFocusedInput,
1616
useWindowDimensions,
17-
} from "react-native-keyboard-controller";
17+
} from "../../hooks";
1818

1919
import { useSmoothKeyboardHandler } from "./useSmoothKeyboardHandler";
2020
import { debounce, scrollDistanceWithRespectToSnapPoints } from "./utils";

src/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
withTiming,
77
} from "react-native-reanimated";
88

9-
import { useKeyboardHandler } from "react-native-keyboard-controller";
9+
import { useKeyboardHandler } from "../../hooks";
1010

1111
const IS_ANDROID_ELEVEN_OR_HIGHER =
1212
Platform.OS === "android" && Platform.Version >= 30;

src/components/KeyboardStickyView/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Reanimated, {
44
useAnimatedStyle,
55
} from "react-native-reanimated";
66

7-
import { useReanimatedKeyboardAnimation } from "react-native-keyboard-controller";
7+
import { useReanimatedKeyboardAnimation } from "../../hooks";
88

99
import type { View, ViewProps } from "react-native";
1010

src/components/KeyboardToolbar/index.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
import React, { useCallback, useEffect, useMemo, useState } from "react";
22
import { StyleSheet, Text, View } from "react-native";
33

4-
import {
5-
FocusedInputEvents,
6-
KeyboardStickyView,
7-
} from "react-native-keyboard-controller";
8-
9-
import { KeyboardController } from "../../bindings";
4+
import { FocusedInputEvents, KeyboardController } from "../../bindings";
105
import useColorScheme from "../hooks/useColorScheme";
6+
import KeyboardStickyView from "../KeyboardStickyView";
117

128
import Arrow from "./Arrow";
139
import Button from "./Button";

0 commit comments

Comments
 (0)