Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException in initDummyLayoutWithHeader #2745

Open
chenxiangcxc opened this issue Feb 27, 2025 · 3 comments
Open

NullPointerException in initDummyLayoutWithHeader #2745

chenxiangcxc opened this issue Feb 27, 2025 · 3 comments
Labels
Missing repro This issue need minimum repro scenario Platform: Android This issue is specific to Android

Comments

@chenxiangcxc
Copy link

chenxiangcxc commented Feb 27, 2025

Description

Hey team, we've observed a crash on Android in initDummyLayoutWithHeader with below code

        // We know the title text view will be there, cause we've just set title.
        defaultFontSize = ScreenStackHeaderConfig.findTitleTextViewInToolbar(toolbar)!!.textSize
Image

Can we avoid the not-null assertion here? Maybe like:

        ScreenStackHeaderConfig.findTitleTextViewInToolbar(toolbar)?.let {
            defaultFontSize = it.textSize
        }

Steps to reproduce

Create an simple screen with below code

const Stack = createStackNavigator();

export default function App() {
  return (
    <NavigationContainer>
      <Stack.Navigator>
        <Stack.Screen name="GiftCards" component={TestScreen}/>
      </Stack.Navigator>
    </NavigationContainer>
  );
}

function TestScreen() {
  return (
    <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
      <Text style={{ fontSize: 24, fontWeight: 'bold' }}>Test</Text>
    </View>
  );
}

Snack or a link to a repository

https://github.com/software-mansion/react-native-screens

Screens version

4.9.1

React Native version

0.78.0

Platforms

Android

JavaScript runtime

None

Workflow

None

Architecture

None

Build type

None

Device

None

Device model

No response

Acknowledgements

Yes

@github-actions github-actions bot added Missing repro This issue need minimum repro scenario Platform: Android This issue is specific to Android labels Feb 27, 2025
Copy link

Hey! 👋

The issue doesn't seem to contain a minimal reproduction.

Could you provide a snack or a link to a GitHub repository under your username that reproduces the problem?

@kkafar
Copy link
Member

kkafar commented Feb 27, 2025

Hey @chenxiangcxc, do you reproduce this error reliably? I'm running your repro & it runs just fine.

Please provide me with more details, so that I can reproduce the error.

Image

I've never observer this error when using the library daily.

@kkafar kkafar added the Close when stale This issue is going to be closed when there is no activity for a while label Feb 27, 2025
@chenxiangcxc
Copy link
Author

Hey @kkafar I can always get this issue in my project reliably but I can't tell why you can't see it.
But I am sure the crash is cause by the not-null assertion, when I remove the assertion then my app works well.

Could you have a proper change on that?

@github-actions github-actions bot removed the Close when stale This issue is going to be closed when there is no activity for a while label Feb 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Missing repro This issue need minimum repro scenario Platform: Android This issue is specific to Android
Projects
None yet
Development

No branches or pull requests

2 participants