mirror of
https://github.com/zhigang1992/react-native-paper.git
synced 2026-06-10 07:19:40 +08:00
fix: fixed android flash crash when subtitle =' ' (empty string) (#469)
reference: https://github.com/wix/react-native-navigation/issues/2892 in short, javascript A && B syntax will return A if A is false. if A is empty string, it will return empty string (which is false if evaluated as boolean) this most of the time works but not here. {A && `<Text>sth</Text>`}, will return "" when A is empty string. This have no problem in iPhone, but returning an empty string to rn component other that` <Text> `will crash in android. The fatal error message can only be viewed using android device monitor or logcat, no message will show in console (as it is a flash crash). To reproduce, put an empty string in subtitle. the double !! first turn empty string '' to true and then false. return false or null is save within JSX 07-26 21:07:41.735: E/AndroidRuntime(16154): java.lang.RuntimeException: abi26_0_0.com.facebook.react.uimanager.IllegalViewOperationException: Trying to add unknown view tag: 1472 07-26 21:07:41.735: E/AndroidRuntime(16154): detail: View tag:1479 07-26 21:07:41.735: E/AndroidRuntime(16154): children(2): [ 07-26 21:07:41.735: E/AndroidRuntime(16154): 1468,1470, 07-26 21:07:41.735: E/AndroidRuntime(16154): ], 07-26 21:07:41.735: E/AndroidRuntime(16154): viewsToAdd(1): [ 07-26 21:07:41.735: E/AndroidRuntime(16154): [2,1472], 07-26 21:07:41.735: E/AndroidRuntime(16154): ], 07-26 21:07:41.735: E/AndroidRuntime(16154): at abi26_0_0.com.facebook.react.bridge.ReactContext.handleException(ReactContext.java:313) 07-26 21:07:41.735: E/AndroidRuntime(16154): at abi26_0_0.com.facebook.react.uimanager.GuardedFrameCallback.doFrame(GuardedFrameCallback.java:33) <!-- Please provide enough information so that others can review your pull request. --> <!-- Keep pull requests small and focused on a single change. --> ### Motivation <!-- What existing problem does the pull request solve? Can you solve the issue with a different approach? --> ### Test plan <!-- List the steps with which we can test this change. Provide screenshots if this changes anything visual. -->
This commit is contained in:
committed by
Satyajit Sahoo
parent
7d11a8ef07
commit
4fd0442482
@@ -79,14 +79,14 @@ class AppbarContent extends React.Component<Props> {
|
||||
>
|
||||
{title}
|
||||
</Text>
|
||||
{subtitle && (
|
||||
{subtitle ? (
|
||||
<Text
|
||||
style={[styles.subtitle, { color: subtitleColor }, subtitleStyle]}
|
||||
numberOfLines={1}
|
||||
>
|
||||
{subtitle}
|
||||
</Text>
|
||||
)}
|
||||
) : null}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user