Skip to content

fix: shutdown ImageLoader onDropViewInstance on android #311

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

Conversation

johankasperi
Copy link
Contributor

PR Description

imageLoader.shutdown() is called onDetachedFromWindow. But this lifecycle method is called when opening a modal on top of the current view containing bottom tabs. When then closing the modal the ImageLoader has been shutdown and wont load icons anymore. Solved this by checking if imageLoader is null in the getDrawable method and if so creates it again.

Fixes #309

How to test?

  1. Download fork at https://github.com/johankasperi/react-native-bottom-tabs/tree/android-modal-tabbaricon-bug
  2. Run example app on Android
  3. Open "Embedded Stacks" example
  4. Open the modal and close it again
  5. Change between the tabs and see that the icon changes when they are focused

Copy link

changeset-bot bot commented Feb 20, 2025

🦋 Changeset detected

Latest commit: 137adaf

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
react-native-bottom-tabs Patch
@bottom-tabs/expo-template Patch
@bottom-tabs/react-navigation Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Collaborator

@okwasniewski okwasniewski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking into this!

@johankasperi johankasperi force-pushed the recreate-android-imageloader-if-shutdown branch from 05a184e to 648fa69 Compare February 20, 2025 18:57
Copy link
Collaborator

@okwasniewski okwasniewski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for changing it! One more small nit and we are good to go

@@ -384,6 +384,10 @@ class ReactBottomNavigationView(context: Context) : LinearLayout(context) {
updateTextAppearance()
}

fun shutdownImageLoader() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Can we call this onDropViewInstance? If in the future there is some other deinit code then we will have universal function to do so.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course! Will fix asap

@johankasperi johankasperi force-pushed the recreate-android-imageloader-if-shutdown branch from 648fa69 to 574d8d6 Compare February 21, 2025 09:28
@johankasperi johankasperi changed the title fix: recreate ImageLoader on android if it has been shutdown fix: shutdown ImageLoader onDropViewInstance on android Feb 21, 2025
Copy link
Collaborator

@okwasniewski okwasniewski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this!

@okwasniewski okwasniewski added this pull request to the merge queue Feb 21, 2025
Merged via the queue into callstackincubator:main with commit 3d0ac88 Feb 21, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dynamic tabBarIcon stops working on Android when opening a modal if tab hasn't been previously focused
2 participants