fix: adjust behavior of empty string in badge prop#378
Merged
okwasniewski merged 1 commit intomainfrom Jul 6, 2025
Merged
Conversation
🦋 Changeset detectedLatest commit: e51f2e8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
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 |
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR standardizes how an empty badge string is handled across Android and iOS by making the badge prop optional and requiring a space (" ") to display a dot badge.
- Default
getBadgefallback updated to useroute.badgedirectly. - Native code on both platforms changed to treat badges as optional and removed the empty-string check on iOS.
- Documentation and example updated to instruct users to pass a space for a “dot” badge.
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/react-native-bottom-tabs/src/TabView.tsx | Added default getBadge fallback to route.badge |
| packages/react-native-bottom-tabs/ios/TabViewProvider.swift | Made badge property optional and updated initializer parsing |
| packages/react-native-bottom-tabs/ios/TabViewImpl.swift | Removed !data.isEmpty check so any non-nil badge shows a dot |
| packages/react-native-bottom-tabs/android/src/main/java/com/rcttabview/RCTTabViewImpl.kt | Made badge nullable and updated JSON parsing |
| packages/react-native-bottom-tabs/android/src/main/java/com/rcttabview/RCTTabView.kt | Changed badge visibility check to item.badge?.isNotEmpty() == true |
| docs/docs/docs/guides/usage-with-react-navigation.mdx | Added warning about passing a space (" ") to show a dot badge |
| docs/docs/docs/guides/standalone-usage.md | Updated example formatting; missing badge warning should be added |
| apps/example/src/Examples/FourTabs.tsx | Added badge: ' ' example for dot badge |
| .changeset/khaki-maps-lay.md | Recorded change in behavior of empty badge prop |
Comments suppressed due to low confidence (3)
docs/docs/docs/guides/standalone-usage.md:29
- Add a warning here similar to the other guide, indicating that to display a dot badge you need to pass a space character (
" ").
export default function TabViewExample() {
packages/react-native-bottom-tabs/ios/TabViewImpl.swift:275
- Introduce unit or snapshot tests verifying that passing an empty string vs. a space string yields the correct badge behavior on iOS.
if let data {
packages/react-native-bottom-tabs/src/TabView.tsx:181
- [nitpick] Update the TypeScript definitions (e.g., BaseRoute or TabViewProps) so that
badgeis explicitlystring | undefined, ensuring consumers get correct type hints.
getBadge = ({ route }: { route: Route }) => route.badge,
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Description
This PR adjusts the behavior of empty string in the badge prop. It provides a consistent experience across platforms, now to get a "dot" badge you need to pass an empty space
" ", this is a limitation of iOS prop parsing where std::string is always initialized as an empty string.Here is a comparison of Android/iOS 18/iOS 26