Skip to content

Commit

Permalink
[RNBS-026] - fix issue with non-discoverable static props
Browse files Browse the repository at this point in the history
  • Loading branch information
kirillzyusko committed May 20, 2022
1 parent 3254d9e commit 666f04b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/optimized.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,20 @@ const optimized = <T extends {}>(screenName: string): any => {
}
}

const OptimizedComponentForwardedRef = React.forwardRef((props: Props<T>, ref: React.Ref<T> | null) => {
return <OptimizedComponent {...props} forwardedRef={ref} />;
});

const registerData = mapLoadable[screenName];

if (registerData.static) {
Object.keys(registerData.static).forEach((key: string) => {
// @ts-ignore
OptimizedComponent[key] = registerData.static[key];
OptimizedComponentForwardedRef[key] = registerData.static[key];
});
}

return React.forwardRef((props: Props<T>, ref: React.Ref<T> | null) => {
return <OptimizedComponent {...props} forwardedRef={ref} />;
});
return OptimizedComponentForwardedRef;
};

export default optimized;

0 comments on commit 666f04b

Please sign in to comment.