Skip to content

Commit 3b13e53

Browse files
committed
chore(SearchInputBar): Update README
1 parent 72d0440 commit 3b13e53

File tree

3 files changed

+38
-3
lines changed

3 files changed

+38
-3
lines changed

example/examples/src/routes/SearchInputBar/index.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, {Component} from 'react';
2-
import {StyleSheet, View} from 'react-native';
2+
import {StyleSheet, View, TextInput} from 'react-native';
33
import Layout, {Container} from '../../Layout';
44
import {SearchInputBar, Toast} from '@uiw/react-native';
55
import {ComProps} from '../../routes';
@@ -14,6 +14,7 @@ export interface IndexState {
1414

1515
export default class Index extends Component<IndexProps, IndexState> {
1616
static state: IndexState;
17+
ref = React.createRef<SearchInputBar>();
1718
constructor(props: IndexProps) {
1819
super(props);
1920
this.state = {
@@ -38,11 +39,13 @@ export default class Index extends Component<IndexProps, IndexState> {
3839
<Body>
3940
<View style={styles.divider} />
4041
<SearchInputBar
42+
ref={this.ref}
4143
onChangeText={val => this.onChangeText(val, 'value')}
4244
onClear={() => this.onClear('value')}
4345
value={this.state.value}
4446
button={{
45-
onPress() {
47+
onPress: () => {
48+
console.log('object', this.ref);
4649
Toast.info('你点击了搜索', 2, 'info');
4750
},
4851
}}

packages/core/src/SearchInputBar/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,38 @@ function Demo() {
5454
}
5555
```
5656

57+
## 获取输入框 Ref
58+
59+
```jsx
60+
import { Fragment, useRef } from 'react';
61+
import { SearchInputBar } from '@uiw/react-native';
62+
function Demo() {
63+
const inputRef = useRef()
64+
return (
65+
<Fragment>
66+
<SearchInputBar
67+
ref={inputRef}
68+
onChangeText={setValue}
69+
onClear={()=>setValue('')}
70+
value={value}
71+
placeholder="请输入搜索关键字"
72+
actionName="搜一下"
73+
showActionButton
74+
button={{
75+
onPress() {
76+
// 点击搜索按钮触法
77+
}
78+
}}
79+
/>
80+
<Button
81+
onPress={()=>{
82+
console.log(inputRef.current.inputRef)
83+
}}
84+
>获取 输入框 Ref</Button>
85+
</Fragment>
86+
);
87+
}
88+
```
5789

5890
## Props
5991

packages/core/src/SearchInputBar/RightButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export default class RightButton extends React.PureComponent<RightButtonProps, R
2323
const { isShow = false, actionName = '搜索', width, ...other } = this.props;
2424
return (
2525
<View style={[styles.rightStyle, { width: width - 10, opacity: Number(isShow) }]}>
26-
<Button type="primary" {...other} style={{ flex: 1, paddingHorizontal: 10 }}>
26+
<Button type="primary" {...other} style={[{ flex: 1, paddingHorizontal: 10 }, other.textStyle]}>
2727
{actionName}
2828
</Button>
2929
</View>

0 commit comments

Comments
 (0)