Skip to content

Commit 2d1636d

Browse files
author
William Porto
committed
chore(components): adding deprecation warning to KeyboardAwareScrollView
1 parent b5543fb commit 2d1636d

File tree

2 files changed

+44
-42
lines changed

2 files changed

+44
-42
lines changed
Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
1-
import React, { FC, ReactNode } from 'react';
1+
import React, { FC, ReactNode } from "react";
22
import {
33
KeyboardAwareScrollView,
4-
KeyboardAwareScrollViewProps
5-
} from 'react-native-keyboard-aware-scroll-view';
4+
KeyboardAwareScrollViewProps,
5+
} from "react-native-keyboard-aware-scroll-view";
66

7-
interface KeyboardAwareScrollViewComponentProps extends KeyboardAwareScrollViewProps {
7+
interface KeyboardAwareScrollViewComponentProps
8+
extends KeyboardAwareScrollViewProps {
89
children: ReactNode;
910
}
1011

11-
const KeyboardAwareScrollViewComponent: FC<KeyboardAwareScrollViewComponentProps> = ({
12-
children,
13-
...rest
14-
}) => (
15-
<KeyboardAwareScrollView
16-
showsVerticalScrollIndicator={false}
17-
showsHorizontalScrollIndicator={false}
18-
{...rest}
19-
>
20-
{children}
21-
</KeyboardAwareScrollView>
22-
);
12+
/**
13+
* @deprecated https://github.com/APSL/react-native-keyboard-aware-scroll-view/issues/494#issuecomment-900089166
14+
*/
15+
const KeyboardAwareScrollViewComponent: FC<KeyboardAwareScrollViewComponentProps> =
16+
({ children, ...rest }) => (
17+
<KeyboardAwareScrollView
18+
showsVerticalScrollIndicator={false}
19+
showsHorizontalScrollIndicator={false}
20+
{...rest}
21+
>
22+
{children}
23+
</KeyboardAwareScrollView>
24+
);
2325

2426
export default KeyboardAwareScrollViewComponent;

template/src/screens/Form/Form.tsx

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import React, { FC, useRef, MutableRefObject, useState } from 'react';
2-
import { useForm, Controller } from 'react-hook-form';
3-
import { yupResolver } from '@hookform/resolvers/yup';
1+
import React, { FC, useRef, MutableRefObject, useState } from "react";
2+
import { ScrollView } from "react-native";
3+
import { useForm, Controller } from "react-hook-form";
4+
import { yupResolver } from "@hookform/resolvers/yup";
45

5-
import { Column, Input, InputRef, Button, KeyboardAwareScrollView } from 'src/components';
6+
import { Column, Input, InputRef, Button } from "src/components";
67

7-
import { FormExampleSchema } from 'src/utils';
8-
import { padding } from 'styled-system';
8+
import { FormExampleSchema } from "src/utils";
99

1010
interface FormExampleData {
1111
email: string;
@@ -17,14 +17,14 @@ const Form: FC = () => {
1717
control,
1818
handleSubmit,
1919
reset,
20-
formState: { errors }
20+
formState: { errors },
2121
} = useForm<FormExampleData>({
22-
reValidateMode: 'onSubmit',
22+
reValidateMode: "onSubmit",
2323
resolver: yupResolver(FormExampleSchema),
2424
defaultValues: {
25-
email: '',
26-
password: ''
27-
}
25+
email: "",
26+
password: "",
27+
},
2828
});
2929
const passwordInputRef = useRef() as MutableRefObject<InputRef>;
3030

@@ -41,22 +41,22 @@ const Form: FC = () => {
4141

4242
return (
4343
<Column flex={1}>
44-
<KeyboardAwareScrollView
44+
<ScrollView
4545
contentContainerStyle={{
4646
flex: 1,
47-
justifyContent: 'center',
48-
padding: 16
47+
justifyContent: "center",
48+
padding: 16,
4949
}}
5050
>
5151
<Controller
52-
name='email'
52+
name="email"
5353
control={control}
5454
render={({ field: { onChange, value } }): JSX.Element => (
5555
<Input
56-
label='E-mail'
57-
placeholder='[email protected]'
58-
keyboardType='email-address'
59-
returnKeyType='next'
56+
label="E-mail"
57+
placeholder="[email protected]"
58+
keyboardType="email-address"
59+
returnKeyType="next"
6060
value={value}
6161
error={errors.email?.message}
6262
onSubmitEditing={() => handleFocus(passwordInputRef)}
@@ -66,15 +66,15 @@ const Form: FC = () => {
6666
/>
6767

6868
<Controller
69-
name='password'
69+
name="password"
7070
control={control}
7171
render={({ field: { onChange, value } }): JSX.Element => (
7272
<Input
7373
ref={passwordInputRef}
7474
secureTextEntry={isPasswordInput}
75-
label='Password'
76-
placeholder='password'
77-
returnKeyType='done'
75+
label="Password"
76+
placeholder="password"
77+
returnKeyType="done"
7878
value={value}
7979
error={errors.password?.message}
8080
onChangeText={onChange}
@@ -84,10 +84,10 @@ const Form: FC = () => {
8484
)}
8585
/>
8686

87-
<Button text='Submit form' onPress={handleSubmit(onSubmit)} mt={20} />
87+
<Button text="Submit form" onPress={handleSubmit(onSubmit)} mt={20} />
8888

89-
<Button variant='secondary' text='Reset form' onPress={() => reset()} />
90-
</KeyboardAwareScrollView>
89+
<Button variant="secondary" text="Reset form" onPress={() => reset()} />
90+
</ScrollView>
9191
</Column>
9292
);
9393
};

0 commit comments

Comments
 (0)