mirror of
https://github.com/zhigang1992/react-native-web.git
synced 2026-04-28 12:24:51 +08:00
[add] TextInput support for isFocused
This commit is contained in:
@@ -157,6 +157,10 @@ Clear the text from the underlying DOM input.
|
|||||||
|
|
||||||
Focus the underlying DOM input.
|
Focus the underlying DOM input.
|
||||||
|
|
||||||
|
**isFocused()**
|
||||||
|
|
||||||
|
Returns `true` if the input is currently focused; `false` otherwise.
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
```js
|
```js
|
||||||
|
|||||||
@@ -72,6 +72,10 @@ class TextInput extends Component {
|
|||||||
TextInputState.focusTextInput(ReactDOM.findDOMNode(this._inputRef));
|
TextInputState.focusTextInput(ReactDOM.findDOMNode(this._inputRef));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isFocused() {
|
||||||
|
return TextInputState.currentlyFocusedField() === ReactDOM.findDOMNode(this._inputRef);
|
||||||
|
}
|
||||||
|
|
||||||
setNativeProps(props) {
|
setNativeProps(props) {
|
||||||
UIManager.updateView(this._inputRef, props, this);
|
UIManager.updateView(this._inputRef, props, this);
|
||||||
}
|
}
|
||||||
@@ -247,8 +251,6 @@ class TextInput extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
applyNativeMethods(TextInput);
|
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
initial: {
|
initial: {
|
||||||
borderColor: 'black'
|
borderColor: 'black'
|
||||||
@@ -284,4 +286,4 @@ const styles = StyleSheet.create({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = TextInput;
|
module.exports = applyNativeMethods(TextInput);
|
||||||
|
|||||||
Reference in New Issue
Block a user