Skip to content

Commit

Permalink
WithReanimated#forwardRef#3
Browse files Browse the repository at this point in the history
  • Loading branch information
ilz5753 committed Dec 14, 2023
1 parent cab8bcf commit fb10669
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ilz5753/rnutils",
"version": "0.1.6",
"version": "0.1.7",
"description": "React Native Utils",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand Down
12 changes: 4 additions & 8 deletions src/dynamicStyles/reanimated.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -649,11 +649,7 @@ export function useDimensionSizesStyle({
}

const $ = Animated.createAnimatedComponent;
export function WithAnimated<T extends object>(
Comp: ComponentType<T>
): ForwardRefExoticComponent<
PropsWithoutRef<Readonly<AnimateProps<T>>> & RefAttributes<T>
> {
export function WithAnimated<T extends object>(Comp: ComponentType<T>) {
class Class<T> extends Component<T> {

Check warning on line 653 in src/dynamicStyles/reanimated.tsx

View workflow job for this annotation

GitHub Actions / lint

'T' is already declared in the upper scope on line 652 column 30
render = () => {
let C = Comp as any;
Expand All @@ -662,9 +658,9 @@ export function WithAnimated<T extends object>(
}
let _Component = isFunction(Comp) ? Class<T> : Comp;
let Render = $(_Component) as any;
return forwardRef<T, Readonly<AnimateProps<T>>>((props, ref) => (
<Render {...{ layout: Layout, ...props, ref }} />
));
return forwardRef<ComponentType<T>, Readonly<AnimateProps<T>>>(
(props, ref) => <Render {...{ layout: Layout, ...props, ref }} />
);
}
export const ReView = WithAnimated(View);
export const ReScrollView = WithAnimated(ScrollView);
Expand Down

0 comments on commit fb10669

Please sign in to comment.