Search code examples
react-nativereact-native-iosexponentjs

TouchableNativeFeedbackSafe.SelectableBackgroundBorderless is not a function


I am trying to use @exponent/react-native-touchable-native-feedback-safe in my react-native based app. I can't seem to set background prop without upsetting either ios or android. I did:

<TouchableNativeFeedbackSafe onPress={this.props.onPress}
    background={TouchableNativeFeedbackSafe.SelectableBackgroundBorderless()}>

this works on android but gives error on iOS: SelectableBackgroundBorderless is not a function.

If I change it from TouchableNativeFeedbackSafe.SelectableBackgroundBorderless() to TouchableNativeFeedbackSafe.SelectableBackgroundBorderless then iOS works but android throws error:

Error while updating property 'nativeBackgroundAndroid' of a view managed by: RCTView
updateViewProp
    ViewManagersPropertyCache.java:89
setProperty
    ViewManagerPropertyUpdater.java:123
updateProps
    ViewManagerPropertyUpdater.java:42
updateProperties
    ViewManager.java:36
createView
    NativeViewHierarchyManager.java:227
execute
   UIViewOperationQueue.java:148
dispatchPendingNonBatchedOperations
   UIViewOperationQueue.java:890
doFrameGuarded
   UIViewOperationQueue.java:863
doFrame
   GuardedChoreographerFrameCallback.java:32
doFrame
   ReactChoreographer.java:131
run
   Choreographer.java:872
...

Solution

  • The reason is a typo in the expo package. Someone forked it and corrected it already: https://github.com/netbeast/react-native-touchable-native-feedback-safe However, I don't think they sent a pull request because the original code isn't publicly available anywhere.

    EDIT:

    TouchableNativeFeedbackSafe.SelectableBackgroundBorderless()
    

    is the correct way to go with the package mentioned above.