Skip to content

Commit

Permalink
Add default values to prevent any regression
Browse files Browse the repository at this point in the history
  • Loading branch information
blazejkustra committed Nov 21, 2023
1 parent 708f080 commit 3949504
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/pages/workspace/withPolicyAndFullscreenLoading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {OnyxEntry, withOnyx} from 'react-native-onyx';
import FullscreenLoadingIndicator from '@components/FullscreenLoadingIndicator';
import compose from '@libs/compose';
import ONYXKEYS from '@src/ONYXKEYS';
import withPolicy, {WithPolicyOnyxProps, WithPolicyProps} from './withPolicy';
import withPolicy, {policyDefaultProps, WithPolicyOnyxProps, WithPolicyProps} from './withPolicy';

type WithPolicyAndFullscreenLoadingOnyxProps = {
/** Indicated whether the report data is loading */
Expand All @@ -20,7 +20,17 @@ type ComponentWithPolicyAndFullscreenLoading<TProps extends WithPolicyAndFullscr
export default function withPolicyAndFullscreenLoading<TProps extends WithPolicyAndFullscreenLoadingProps, TRef>(
WrappedComponent: ComponentType<TProps & RefAttributes<TRef>>,
): ComponentWithPolicyAndFullscreenLoading<TProps, TRef> {
function WithPolicyAndFullscreenLoading({isLoadingReportData = true, policy, policyDraft, ...rest}: TProps, ref: ForwardedRef<TRef>) {
function WithPolicyAndFullscreenLoading(
{
isLoadingReportData = true,
policy = policyDefaultProps.policy,
policyDraft = policyDefaultProps.policyDraft,
policyMembers = policyDefaultProps.policyMembers,
policyMembersDraft = policyDefaultProps.policyMembersDraft,
...rest
}: TProps,
ref: ForwardedRef<TRef>,
) {
if (isLoadingReportData && isEmpty(policy) && isEmpty(policyDraft)) {
return <FullscreenLoadingIndicator />;
}
Expand All @@ -32,6 +42,8 @@ export default function withPolicyAndFullscreenLoading<TProps extends WithPolicy
isLoadingReportData={isLoadingReportData}
policy={policy}
policyDraft={policyDraft}
policyMembers={policyMembers}
policyMembersDraft={policyMembersDraft}
ref={ref}
/>
);
Expand Down

0 comments on commit 3949504

Please sign in to comment.