Skip to content

Commit 3e1dcf6

Browse files
committed
fix: types of components
1 parent e87a0ec commit 3e1dcf6

File tree

9 files changed

+14
-14
lines changed

9 files changed

+14
-14
lines changed

example/src/storybook/stories/PinInput/custom.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import React from 'react';
22
import {
3-
PinInput,
43
SubmitButton,
54
ResetButton,
65
Box,
76
ButtonGroup,
7+
PinInput,
88
} from '@native-base/formik-ui';
99
import { Formik } from 'formik';
1010
import { Heading, FormControl } from 'native-base';
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { PinInput as NBPinInput } from 'native-base';
22
import { useField, useFormikContext } from 'formik';
3-
import React, { FC } from 'react';
3+
import React from 'react';
44
import type { PinInputProps } from './type';
55

6-
export const PinInput: FC<PinInputProps> = (props: PinInputProps, ref: any) => {
7-
const { name, children, PinInputProps, ...rest } = props;
6+
export const PinInput = React.forwardRef((props: PinInputProps, ref: any) => {
7+
const { name, children, pinInputProps, ...rest } = props;
88
const [field, { error }] = useField(name);
99
const { handleChange } = useFormikContext();
1010

@@ -13,12 +13,12 @@ export const PinInput: FC<PinInputProps> = (props: PinInputProps, ref: any) => {
1313
isInvalid={!!error}
1414
onChange={handleChange(name)}
1515
value={field.value}
16-
{...PinInputProps}
16+
{...pinInputProps}
1717
{...rest}
1818
ref={ref}
1919
>
2020
{children}
2121
</NBPinInput>
2222
);
23-
};
24-
export default PinInput;
23+
});
24+
export default React.memo(PinInput);

src/components/FormControlComponents/pin-input/index.tsx renamed to src/components/FormControlComponents/PinInput/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ let PinInputTemp: any = PinInputMain;
66
PinInputTemp.Field = NBPinInput.Field;
77

88
// To add typings
9-
let PinInput = PinInputTemp as PinInputComponentType;
9+
const PinInput = PinInputTemp as PinInputComponentType;
1010

1111
export { PinInput };

src/components/FormControlComponents/pin-input/type.ts renamed to src/components/FormControlComponents/PinInput/type.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ export type PinInputProps = BaseProps & {
66
PinInputProps?: IPinInputProps;
77
children?: ReactNode;
88
};
9-
export type PinInputComponentType = PinInputProps & {
9+
export type PinInputComponentType = ((props: PinInputProps) => JSX.Element) & {
1010
Field: React.MemoExoticComponent<(props: IInputProps) => JSX.Element>;
1111
};
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
export * from './input';
22
export * from './checkbox';
3-
export * from './number-input';
4-
export * from './pin-input';
3+
export * from './NumberInput';
4+
export * from './PinInput';
55
export * from './radio';
66
export * from './select';
77
export * from './slider';
88
export * from './switch';
99
export * from './textarea';
10-
export * from './submit-button';
11-
export * from './reset-button';
10+
export * from './SubmitButton';
11+
export * from './ResetButton';

src/components/FormControlComponents/slider/type.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export type SliderProps = BaseProps & {
66
sliderProps?: ISliderProps;
77
children: ReactNode;
88
};
9-
export type SliderComponentType = SliderProps & {
9+
export type SliderComponentType = ((props: SliderProps) => JSX.Element) & {
1010
Thumb: React.MemoExoticComponent<(props: IBoxProps) => JSX.Element>;
1111
Track: React.MemoExoticComponent<(props: IBoxProps) => JSX.Element>;
1212
FilledTrack: React.MemoExoticComponent<(props: IBoxProps) => JSX.Element>;

0 commit comments

Comments
 (0)