aboutsummaryrefslogtreecommitdiff
path: root/src/client/react/components/container
diff options
context:
space:
mode:
authorNoah Loomans <noahloomans@gmail.com>2017-12-21 13:10:05 +0100
committerNoah Loomans <noahloomans@gmail.com>2017-12-21 13:10:05 +0100
commit4ca30295d7d9f3dd7ba2e105952ff627f6b702a4 (patch)
tree48285ecb1957171ebb9b0106aaf2d1a184972d0e /src/client/react/components/container
parentf0c8cf0e79f003514fd65a70def5820205955a77 (diff)
Add strict typing
Except for functions because of https://github.com/reactjs/redux/issues/2709
Diffstat (limited to 'src/client/react/components/container')
-rw-r--r--src/client/react/components/container/Search.tsx27
1 files changed, 6 insertions, 21 deletions
diff --git a/src/client/react/components/container/Search.tsx b/src/client/react/components/container/Search.tsx
index fdd6c83..b22c26e 100644
--- a/src/client/react/components/container/Search.tsx
+++ b/src/client/react/components/container/Search.tsx
@@ -13,8 +13,8 @@ import users from '../../users';
import Results from './Results';
import IconFromUserType from '../presentational/IconFromUserType';
-interface SearchStatehProps {
- selectedResult: string,
+interface SearchStateProps {
+ selectedResult: string | null,
isExactMatch: boolean,
}
@@ -23,8 +23,8 @@ interface SearchDispatchProps {
inputChange(typedValue: string): void,
}
-class Search extends React.Component<SearchStatehProps & SearchDispatchProps, any> {
- constructor(props: SearchStatehProps & SearchDispatchProps) {
+class Search extends React.Component<SearchStateProps & SearchDispatchProps, any> {
+ constructor(props: SearchStateProps & SearchDispatchProps) {
super(props);
this.state = {
@@ -80,7 +80,7 @@ class Search extends React.Component<SearchStatehProps & SearchDispatchProps, an
<div className="search__input-wrapper">
<div className="search__icon-wrapper">
<IconFromUserType
- userType={isExactMatch ? users.byId[selectedResult].type : null}
+ userType={(selectedResult && isExactMatch) ? users.byId[selectedResult].type : undefined}
defaultIcon={<SearchIcon />}
/>
</div>
@@ -99,26 +99,11 @@ class Search extends React.Component<SearchStatehProps & SearchDispatchProps, an
}
}
-// Search.propTypes = {
-// selectedResult: PropTypes.string,
-// isExactMatch: PropTypes.bool.isRequired,
-// dispatch: PropTypes.func.isRequired,
-// };
-
-// Search.defaultProps = {
-// selectedResult: null,
-// };
-
-const mapStateToProps = (state: State):SearchStatehProps => ({
+const mapStateToProps = (state: State):SearchStateProps => ({
selectedResult: state.search.selectedResult,
isExactMatch: state.search.isExactMatch,
});
-// const mapDispatchToProps = {
-// inputChange,
-// changeSelectedResult,
-// };
-
const mapDispatchToProps = (dispatch: any): SearchDispatchProps => ({
inputChange(typedValue) {
dispatch(inputChange(typedValue));