ardaogulcan / react-native-keyboard-accessory

A React Native Keyboard Accessory (View, Navigation) Component. Sticky views on keyboard.
MIT License
534 stars 64 forks source link

Optionally allow children to accept a function #51

Closed jdmunro closed 4 years ago

jdmunro commented 4 years ago

This PR is a simple change that enables you to pass a render prop to KeyboardAccessoryView.

I've found in multiple applications that it's really convenient to be able to render different views depending on whether the keyboard is visible or not. By using a render prop it allows us a really convenient way to do this, without having to subscribe to any events.

e.g:

<KeyboardAccessoryView alwaysVisible>
  {({isKeyboardVisible}) => {
    return (
      <>
        <Text>My Keyboard Accessory</Text>
        {!isKeyboardVisible ? (
          <Text>Hidden when keyboard is visible</Text>
        ) : null}
      </>
    )
  }}
</KeyboardAccessoryView>

Since this is optional, it is a non-breaking change.

ardaogulcan commented 4 years ago

Hi @jdmunro, thank you for the PR it is a good one and looks good to me. Can you also document this to README.md ?

jdmunro commented 4 years ago

Sure @ardaogulcan - I've added a few lines to show how to use the feature. Thanks for building the library 🎉

ardaogulcan commented 4 years ago

Released with v0.1.11