Skip to content

Commit f361221

Browse files
authored
chore(JS): RNSLog remove from public API (#3744)
## Description This PR moves `RNSLog` utility out of the library's public API as discussed there: #3733 (review) ## Changes - move `RNSLog` to `react-native-screens/private` - remove `bottomTabsDebugLog` - update `useRenderDebugInfo` - update logging in `StackContainer` and `BottomTabsContainer` ## Before & after - visual documentation N/A ## Test plan ## Checklist - [ ] Included code example that can be used to test this change. - [ ] Updated / created local changelog entries in relevant test files. - [ ] For visual changes, included screenshots / GIFs / recordings documenting the change. - [ ] For API changes, updated relevant public types. - [ ] Ensured that CI passes
1 parent 6b27a45 commit f361221

16 files changed

Lines changed: 57 additions & 75 deletions

File tree

FabricExample/App.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ featureFlags.experiment.androidResetScreenShadowStateOnOrientationChangeEnabled
88
true;
99
featureFlags.experiment.iosPreventReattachmentOfDismissedScreens = true;
1010
featureFlags.experiment.ios26AllowInteractionsDuringTransition = true;
11+
featureFlags.stable.debugLogging = true;
1112

1213
export default App;

TVOSExample/App.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
import App from '../apps';
2+
import { featureFlags } from 'react-native-screens';
3+
4+
featureFlags.stable.debugLogging = true;
25

36
export default App;

apps/App.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import React from 'react';
2-
import { enableFreeze, featureFlags } from 'react-native-screens';
2+
import { enableFreeze } from 'react-native-screens';
33

44
import Example from './Example';
55
// import { NavigationContainer } from '@react-navigation/native';
66
// import { Tests } from './src/tests';
77

88
enableFreeze(true);
9-
featureFlags.stable.debugLogging = true;
109

1110
export default function App() {
1211
return <Example />;

apps/src/shared/gamma/containers/bottom-tabs/BottomTabsContainer.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
import SafeAreaView from '../../../../../../src/components/safe-area/SafeAreaView';
1010
import type { SafeAreaViewProps } from '../../../../../../src/components/safe-area/SafeAreaView.types';
1111
import ConfigWrapperContext from './ConfigWrapperContext';
12+
import { RNSLog } from 'react-native-screens/private';
1213

1314
export interface TabConfiguration {
1415
tabScreenProps: TabsScreenProps;
@@ -21,12 +22,12 @@ export type BottomTabsContainerProps = TabsHostProps & {
2122
};
2223

2324
export function BottomTabsContainer(props: BottomTabsContainerProps) {
24-
console.info('BottomTabsContainer render');
25+
RNSLog.info('BottomTabsContainer render');
2526

2627
const { tabConfigs, ...restProps } = props;
2728

2829
const [focusedScreenKey, setFocusedScreenKey] = React.useState<string>(() => {
29-
console.log('BottomTabsContainer focusedStateKey initial state computed');
30+
RNSLog.log('BottomTabsContainer focusedStateKey initial state computed');
3031

3132
if (props.tabConfigs.length === 0) {
3233
throw new Error('There must be at least one tab defined');
@@ -67,7 +68,7 @@ export function BottomTabsContainer(props: BottomTabsContainerProps) {
6768
// };
6869

6970
transitionFn(() => {
70-
console.info(`Starting transition to ${screenKey}`);
71+
RNSLog.info(`Starting transition to ${screenKey}`);
7172
setFocusedScreenKey(screenKey);
7273
});
7374
},
@@ -85,8 +86,9 @@ export function BottomTabsContainer(props: BottomTabsContainerProps) {
8586
{...restProps}>
8687
{tabConfigs.map(tabConfig => {
8788
const screenKey = tabConfig.tabScreenProps.screenKey;
88-
const isFocused = tabConfig.tabScreenProps.screenKey === focusedScreenKey;
89-
console.info(
89+
const isFocused =
90+
tabConfig.tabScreenProps.screenKey === focusedScreenKey;
91+
RNSLog.info(
9092
`BottomTabsContainer map to component -> ${screenKey} ${
9193
isFocused ? '(focused)' : ''
9294
}`,

apps/src/shared/gamma/containers/stack/StackContainer.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
} from './contexts/StackNavigationContext';
1818
import {
1919
type NativeComponentGenericRef,
20+
RNSLog,
2021
useRenderDebugInfo,
2122
} from 'react-native-screens/private';
2223
import { useParentNavigationEffect } from './hooks/useParentNavigationEffect';
@@ -44,15 +45,15 @@ export function StackContainer({ routeConfigs }: StackContainerProps) {
4445

4546
const onScreenDismissed = React.useCallback(
4647
(screenKey: string) => {
47-
console.log(`onScreenDismissed for ${screenKey}`);
48+
RNSLog.log(`onScreenDismissed for ${screenKey}`);
4849
navMethods.popCompletedAction(screenKey);
4950
},
5051
[navMethods],
5152
);
5253

5354
const onScreenNativelyDismissed = React.useCallback(
5455
(screenKey: string) => {
55-
console.log(`onScreenNativelyDismissed for ${screenKey}`);
56+
RNSLog.log(`onScreenNativelyDismissed for ${screenKey}`);
5657
navMethods.popNativeAction(screenKey);
5758
},
5859
[navMethods],

apps/src/tests/issue-tests/TestBottomTabs/index.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@ import {
1414
} from '../../../shared/gamma/containers/bottom-tabs/BottomTabsContainer';
1515
import { Tab1, Tab2, Tab3, Tab4 } from './tabs';
1616
import Colors from '../../../shared/styling/Colors';
17-
import { internalEnableDetailedBottomTabsLogging } from 'react-native-screens/private';
1817

1918
enableFreeze(true);
20-
internalEnableDetailedBottomTabsLogging();
2119

2220
const DEFAULT_APPEARANCE_ANDROID: TabsScreenAppearanceAndroid = {
2321
tabBarBackgroundColor: Colors.NavyLight100,

apps/src/tests/issue-tests/TestBottomTabsOrientation.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
type TabConfiguration,
1111
} from '../../shared/gamma/containers/bottom-tabs/BottomTabsContainer';
1212
import Colors from '../../shared/styling/Colors';
13-
import { internalEnableDetailedBottomTabsLogging } from 'react-native-screens/private';
1413
import { Button, ScrollView, Text, View } from 'react-native';
1514
import {
1615
NavigationContainer,
@@ -20,7 +19,6 @@ import {
2019
import { createNativeStackNavigator } from '@react-navigation/native-stack';
2120

2221
enableFreeze(true);
23-
internalEnableDetailedBottomTabsLogging();
2422

2523
function ScreenComponent() {
2624
return (

src/components/tabs/host/TabsHost.android.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ import TabsHostAndroidNativeComponent, {
66
type NativeProps as TabsHostAndroidNativeComponentProps,
77
} from '../../../fabric/tabs/TabsHostAndroidNativeComponent';
88
import type { TabsHostProps } from './TabsHost.types';
9-
import { bottomTabsDebugLog } from '../../../private/logging';
9+
import { RNSLog } from '../../../private';
1010
import { useTabsHost } from './useTabsHost';
1111

1212
/**
1313
* EXPERIMENTAL API, MIGHT CHANGE W/O ANY NOTICE
1414
*/
1515
function TabsHost(props: TabsHostProps) {
16-
bottomTabsDebugLog(`TabsHost render`);
16+
RNSLog.log(`TabsHost render`);
1717

1818
// android props (even if unused for now) are extracted - these should be handled separately from base props
1919
// ios props are safely dropped

src/components/tabs/host/TabsHost.ios.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import TabsHostIOSNativeComponent, {
66
type NativeProps as TabsHostIOSNativeComponentProps,
77
} from '../../../fabric/tabs/TabsHostIOSNativeComponent';
88
import type { TabsHostProps } from './TabsHost.types';
9-
import { bottomTabsDebugLog } from '../../../private/logging';
9+
import { RNSLog } from '../../../private';
1010
import TabsBottomAccessory from '../bottom-accessory/TabsBottomAccessory';
1111
import { TabsBottomAccessoryEnvironment } from '../bottom-accessory/TabsBottomAccessory.types';
1212
import TabsBottomAccessoryContent from '../bottom-accessory/TabsBottomAccessoryContent';
@@ -17,7 +17,7 @@ import { useTabsHost } from './useTabsHost';
1717
* EXPERIMENTAL API, MIGHT CHANGE W/O ANY NOTICE
1818
*/
1919
function TabsHost(props: TabsHostProps) {
20-
bottomTabsDebugLog(`TabsHost render`);
20+
RNSLog.log(`TabsHost render`);
2121

2222
// android props are safely dropped
2323
// eslint-disable-next-line @typescript-eslint/no-unused-vars

src/components/tabs/host/useTabsHost.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { findNodeHandle, type NativeSyntheticEvent } from 'react-native';
33
import type { NativeProps as TabsHostAndroidNativeComponentProps } from '../../../fabric/tabs/TabsHostAndroidNativeComponent';
44
import type { NativeProps as TabsHostIOSNativeComponentProps } from '../../../fabric/tabs/TabsHostIOSNativeComponent';
55
import featureFlags from '../../../flags';
6-
import { bottomTabsDebugLog } from '../../../private/logging';
6+
import { RNSLog } from '../../../private';
77
import type { NativeFocusChangeEvent } from './TabsHost.types';
88

99
type TabsHostPlatformNativeComponentProps =
@@ -36,7 +36,7 @@ export function useTabsHost<T extends TabsHostPlatformNativeComponentProps>({
3636

3737
const onNativeFocusChangeCallback = React.useCallback(
3838
(event: NativeSyntheticEvent<NativeFocusChangeEvent>) => {
39-
bottomTabsDebugLog(
39+
RNSLog.log(
4040
`TabsHost [${
4141
componentNodeHandle.current ?? -1
4242
}] onNativeFocusChange: ${JSON.stringify(event.nativeEvent)}`,

0 commit comments

Comments
 (0)