Skip to content

Commit 1173554

Browse files
committed
[unit-testing] Fixed soanr issue
1 parent cd76e1a commit 1173554

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

src/packages/react-native-material-elements/src/components/Menu/Menu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export const Menu = React.forwardRef<View, MenuProps>(
117117
}, [anchorEl, menuRect, menuYPosSpacer]);
118118

119119
const animatedStyles: ViewStyle = {
120-
transform: [{ translateX: !fullWidth ? calculateXPosition : 0 }, { translateY: calculateYPosition + elemSpace }],
120+
transform: [{ translateX: fullWidth ? 0 : calculateXPosition }, { translateY: calculateYPosition + elemSpace }],
121121
};
122122

123123
const menuViewOnLayout = function (event: LayoutChangeEvent) {

src/packages/react-native-material-elements/src/components/Snackbar/Snackbar.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ export const Snackbar: React.FC<SnackbarProps> = ({
147147
}, [position]);
148148

149149
useEffect(() => {
150-
if (snackbarConfig?.autoHide !== undefined) {
150+
if (snackbarConfig?.autoHide) {
151151
autoHideRef.current = snackbarConfig.autoHide;
152152
} else {
153153
autoHideRef.current = autoHide;
@@ -198,10 +198,8 @@ export const Snackbar: React.FC<SnackbarProps> = ({
198198
}, [snackbarConfig, opacityValue, positionRef, snackbarRootRectangle, translateY, screenHeight, autoHideRef]);
199199

200200
const startAnimation = useCallback(() => {
201-
const translateYToValue =
202-
positionRef.current === 'top'
203-
? 30 + extraSpace
204-
: screenHeight - (snackbarRootRectangle?.height ? snackbarRootRectangle.height + SNACK_BAR_SCREEN_GAP : 100) - extraSpace;
201+
const snackbarHeight = snackbarRootRectangle?.height ? snackbarRootRectangle.height + SNACK_BAR_SCREEN_GAP : 100;
202+
const translateYToValue = positionRef.current === 'top' ? 30 + extraSpace : screenHeight - snackbarHeight - extraSpace;
205203

206204
Animated.parallel([
207205
Animated.timing(opacityValue, {

src/packages/react-native-material-elements/src/components/TextField/OtpInput.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export const OTPInput: React.FC<OTPInputProps> = ({
8282
testID = 'otp-input',
8383
...props
8484
}) => {
85-
const [otp, setOtp] = useState<string[]>(Array(length).fill(''));
85+
const [otp, setOtp] = useState<string[]>(new Array(length).fill(''));
8686
const [focusedIndex, setFocusedIndex] = useState<number | null>(null);
8787
const inputs = useRef<TextInput[]>([]);
8888

@@ -131,15 +131,15 @@ export const OTPInput: React.FC<OTPInputProps> = ({
131131
};
132132

133133
useEffect(() => {
134-
setOtp(Array(length).fill(''));
134+
setOtp(new Array(length).fill(''));
135135
}, [length]);
136136

137137
useEffect(() => {
138138
if (defaultValue) {
139139
const defaultValueLength = defaultValue.toString();
140140

141141
if (defaultValueLength.length > length) {
142-
throw Error('Default value must be equal or less then otp length');
142+
throw new Error('Default value must be equal or less then otp length');
143143
}
144144

145145
const otpArray = defaultValueLength.split('').concat(Array(length - defaultValueLength.length).fill(''));

0 commit comments

Comments
 (0)