Skip to content

Commit

Permalink
fix: type definition of search-bar
Browse files Browse the repository at this point in the history
  • Loading branch information
BANG88 committed Aug 21, 2019
1 parent d1b98c9 commit e0fc3f3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
6 changes: 4 additions & 2 deletions components/search-bar/PropsType.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { NativeSyntheticEvent, TextInputFocusEventData } from "react-native";

function noop() {}

export interface SearchBarPropsType {
Expand All @@ -6,8 +8,8 @@ export interface SearchBarPropsType {
placeholder?: string;
onSubmit?: (value: string) => void;
onChange?: (value: string) => void;
onFocus?: () => void;
onBlur?: () => void;
onFocus?: (e: NativeSyntheticEvent<TextInputFocusEventData>) => void;
onBlur?: (e: NativeSyntheticEvent<TextInputFocusEventData>) => void;
onCancel?: (value: string) => void;
showCancelButton?: boolean;
cancelText?: string;
Expand Down
11 changes: 5 additions & 6 deletions components/search-bar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

import PropTypes from 'prop-types';
import React from 'react';
import { StyleProp, Text, TextInput, TextStyle, View } from 'react-native';
import { NativeSyntheticEvent, StyleProp, Text, TextInput, TextInputFocusEventData, TextStyle, View } from 'react-native';
import Icon from '../icon';
import { WithTheme, WithThemeStyles } from '../style';
import { getComponentLocale } from '../_util/getLocale';
Expand Down Expand Up @@ -75,21 +74,21 @@ export default class SearchBar extends React.Component<
}
};

onFocus = () => {
onFocus = (e: NativeSyntheticEvent<TextInputFocusEventData>) => {
this.setState({
focus: true,
});
if (this.props.onFocus) {
this.props.onFocus();
this.props.onFocus(e);
}
};

onBlur = () => {
onBlur = (e: NativeSyntheticEvent<TextInputFocusEventData>) => {
this.setState({
focus: false,
});
if (this.props.onBlur) {
this.props.onBlur();
this.props.onBlur(e);
}
};
render() {
Expand Down

0 comments on commit e0fc3f3

Please sign in to comment.