Skip to content

Commit

Permalink
refactor: separate API props and NativeProps
Browse files Browse the repository at this point in the history
  • Loading branch information
maciekstosio committed Oct 25, 2024
1 parent 5b9b8bd commit 4153a8e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
20 changes: 15 additions & 5 deletions src/components/ScreenStack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { freezeEnabled } from '../core';
import DelayedFreeze from './helpers/DelayedFreeze';

// Native components
import ScreenStackNativeComponent from '../fabric/ScreenStackNativeComponent';
const NativeScreenStack: React.ComponentType<ScreenStackProps> =
ScreenStackNativeComponent as any;
import ScreenStackNativeComponent, {
NativeProps,
} from '../fabric/ScreenStackNativeComponent';

function isFabric() {
return 'nativeFabricUIManager' in global;
Expand Down Expand Up @@ -45,9 +45,19 @@ function ScreenStack(props: ScreenStackProps) {
}
});
return (
<NativeScreenStack {...rest} ref={ref}>
<ScreenStackNativeComponent
{...rest}
/**
* This messy override is to conform NativeProps used by codegen and
* our Public API. To see reasoning go to this PR:
* https://github.com/software-mansion/react-native-screens/pull/2423#discussion_r1810616995
*/
onFinishTransitioning={
props.onFinishTransitioning as NativeProps['onFinishTransitioning']
}
ref={ref}>
{childrenWithFreeze}
</NativeScreenStack>
</ScreenStackNativeComponent>
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/fabric/ScreenStackNativeComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { DirectEventHandler } from 'react-native/Libraries/Types/CodegenTyp
// eslint-disable-next-line @typescript-eslint/ban-types
type FinishTransitioningEvent = Readonly<{}>;

interface NativeProps extends ViewProps {
export interface NativeProps extends ViewProps {
onFinishTransitioning?: DirectEventHandler<FinishTransitioningEvent>;
}

Expand Down

0 comments on commit 4153a8e

Please sign in to comment.