Skip to content

Fix/ forwardRef warning #1786

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 19, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export declare type KeyboardTrackingViewProps = ViewProps & {
children?: React.ReactChild | React.ReactChild[];
style?: ViewStyle;
};
declare const _default: React.ForwardRefExoticComponent<Pick<ViewProps & {
declare const KeyboardTrackingView: React.ForwardRefExoticComponent<Pick<ViewProps & {
/**
* Enables tracking of the keyboard when it's dismissed interactively (false by default).
* Why? When using an external keyboard (BT),
Expand All @@ -52,4 +52,4 @@ declare const _default: React.ForwardRefExoticComponent<Pick<ViewProps & {
children?: React.ReactChild | React.ReactChild[] | undefined;
style?: ViewStyle | undefined;
}, keyof ViewProps | "useSafeArea" | "trackInteractive" | "scrollToFocusedInput" | "scrollBehavior" | "revealKeyboardInteractive" | "manageScrollView" | "requiresSameParentToManageScrollView" | "addBottomView" | "allowHitsOutsideBounds"> & React.RefAttributes<unknown>>;
export default _default;
export default KeyboardTrackingView;
4 changes: 2 additions & 2 deletions generatedTypes/src/incubator/ChipsInput/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export declare type ChipsInputProps = Omit<TextFieldProps, 'ref'> & {
*/
maxChips?: number;
};
declare const _default: React.ForwardRefExoticComponent<Omit<TextFieldProps, "ref"> & {
declare const ChipsInput: React.ForwardRefExoticComponent<Omit<TextFieldProps, "ref"> & {
/**
* Chip items to render in the input
*/
Expand All @@ -52,4 +52,4 @@ declare const _default: React.ForwardRefExoticComponent<Omit<TextFieldProps, "re
*/
maxChips?: number | undefined;
} & React.RefAttributes<any>>;
export default _default;
export default ChipsInput;
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ export type KeyboardTrackingViewProps = ViewProps & {
style?: ViewStyle;
}

const KeyboardTrackingView = ({children, ...others}: KeyboardTrackingViewProps, ref: any) => {
const KeyboardTrackingView = forwardRef(({children, ...others}: KeyboardTrackingViewProps, ref: any) => {
const KeyboardTrackingViewContainer = isAndroid ? KeyboardTrackingViewAndroid : KeyboardTrackingViewIOS;

return (
<KeyboardTrackingViewContainer {...others} ref={ref}>
{children}
</KeyboardTrackingViewContainer>
);
};
});

export default forwardRef(KeyboardTrackingView);
export default KeyboardTrackingView;
8 changes: 4 additions & 4 deletions src/incubator/ChipsInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export type ChipsInputProps = Omit<TextFieldProps, 'ref'> & {
maxChips?: number;
};

const ChipsInput = (props: ChipsInputProps, refToForward: React.Ref<any>) => {
const ChipsInput = forwardRef((props: ChipsInputProps, refToForward: React.Ref<any>) => {
const fieldRef = useCombinedRefs(refToForward);
const {
chips = [],
Expand Down Expand Up @@ -150,17 +150,17 @@ const ChipsInput = (props: ChipsInputProps, refToForward: React.Ref<any>) => {
accessibilityHint={props.editable ? 'press keyboard delete button to remove last tag' : undefined}
/>
);
};
});

const styles = StyleSheet.create({
fieldStyle: {
flexWrap: 'wrap'
}
});

// @ts-expect-error
ChipsInput.changeReasons = {
ADDED: 'added',
REMOVED: 'removed'
};

export default forwardRef(ChipsInput);
export default ChipsInput;