Why would React-Navigation documentation not include some of the most important props and functionalities?

94 Views Asked by At

After playing around with React-Navigation's Native Stack headerSearchBarOptions to render a native search bar on iOS in my React-Native project, I wanted to implement search functionality. However, I just couldn't figure out how to apply logic whenever a user hits the search button on their mobile keyboard. In the documentation, there was no option/property that would allow me to call an API when the user presses the search button on their keyboard. There are only onBlur, onCancelButtonPress, and onChangeText, none of which would help me.

So, I spent a considerable amount of time Googling (nothing came up) and playing around with React Native's Keyboard event listeners to achieve the onPressSearch functionality. To my surprise, when I was writing onSearch in VSCode, there was a suggestion of the onSearchButtonPress option in the headerSearchBarOptions, and it worked just like I expected.

If the React-Navigation team had included this option in their documentation, I wouldn't have spent a lot of time trying to reinvent the wheel. Why would they not include it in their documentation since it'll be one of the most important options they provide? If I go to React Native Screens on GitHub, however, I could see the onSearchButtonPress functionality there. Are we as developers expected to assume more options/functionality than what the documentation provides and dig deeper into their repositories on our own, or is it just the React-Navigation team's carelessness?

I tried to implement the onSearchButtonPress functionality on my own when I found it accidentally on VSCode, but it was not in the official documentation.

0

There are 0 best solutions below