Skip to content

Commit fcb8ae9

Browse files
Steve0929satya164
andauthored
Add onSearchButtonPress prop to the headerSearchBarOptions (#1265)
Co-authored-by: Satyajit Sahoo <satyajit.happy@gmail.com>
1 parent 98ebe73 commit fcb8ae9

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

versioned_docs/version-6.x/native-stack-navigator.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,22 @@ A callback that gets called when search bar has lost focus.
376376

377377
A callback that gets called when the cancel button is pressed.
378378

379+
##### `onSearchButtonPress`
380+
381+
A callback that gets called when the search button is pressed.
382+
383+
```js
384+
const [search, setSearch] = React.useState('');
385+
386+
React.useLayoutEffect(() => {
387+
navigation.setOptions({
388+
headerSearchBarOptions: {
389+
onSearchButtonPress: (event) => setSearch(event?.nativeEvent?.text),
390+
},
391+
});
392+
}, [navigation]);
393+
```
394+
379395
##### `onChangeText`
380396
381397
A callback that gets called when the text changes. It receives the current text value of the search bar.

versioned_docs/version-7.x/native-stack-navigator.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,6 +1249,22 @@ A callback that gets called when search bar has lost focus.
12491249

12501250
A callback that gets called when the cancel button is pressed.
12511251

1252+
##### `onSearchButtonPress`
1253+
1254+
A callback that gets called when the search button is pressed.
1255+
1256+
```js
1257+
const [search, setSearch] = React.useState('');
1258+
1259+
React.useLayoutEffect(() => {
1260+
navigation.setOptions({
1261+
headerSearchBarOptions: {
1262+
onSearchButtonPress: (event) => setSearch(event?.nativeEvent?.text),
1263+
},
1264+
});
1265+
}, [navigation]);
1266+
```
1267+
12521268
##### `onChangeText`
12531269
12541270
A callback that gets called when the text changes. It receives the current text value of the search bar.

versioned_docs/version-8.x/native-stack-navigator.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,6 +1252,22 @@ A callback that gets called when search bar has lost focus.
12521252

12531253
A callback that gets called when the cancel button is pressed.
12541254

1255+
##### `onSearchButtonPress`
1256+
1257+
A callback that gets called when the search button is pressed.
1258+
1259+
```js
1260+
const [search, setSearch] = React.useState('');
1261+
1262+
React.useLayoutEffect(() => {
1263+
navigation.setOptions({
1264+
headerSearchBarOptions: {
1265+
onSearchButtonPress: (event) => setSearch(event?.nativeEvent?.text),
1266+
},
1267+
});
1268+
}, [navigation]);
1269+
```
1270+
12551271
##### `onChange`
12561272
12571273
A callback that gets called when the text changes. It receives en event containing the current text value of the search bar.

0 commit comments

Comments
 (0)