Page MenuHomePhabricator

D9769.id33824.diff
No OneTemporary

D9769.id33824.diff

diff --git a/lib/types/react-types.js b/lib/types/react-types.js
new file mode 100644
--- /dev/null
+++ b/lib/types/react-types.js
@@ -0,0 +1,6 @@
+// @flow
+
+// Flow 0.217 introduces React.RefSetter
+export type ReactRefSetter<I> =
+ | { current: null | I, ... }
+ | ((null | I) => mixed);
diff --git a/web/account/password-input.react.js b/web/account/password-input.react.js
--- a/web/account/password-input.react.js
+++ b/web/account/password-input.react.js
@@ -5,6 +5,7 @@
import SWMansionIcon, {
type Icon,
} from 'lib/components/SWMansionIcon.react.js';
+import type { ReactRefSetter } from 'lib/types/react-types.js';
import css from './password-input.css';
import Button from '../components/button.react.js';
@@ -12,7 +13,10 @@
type PasswordInputProps = BaseInputProps;
-function PasswordInput(props: PasswordInputProps, ref): React.Node {
+function PasswordInput(
+ props: PasswordInputProps,
+ ref: ReactRefSetter<HTMLInputElement>,
+): React.Node {
const [htmlInputType, setHtmlInputType] = React.useState<'password' | 'text'>(
'password',
);
diff --git a/web/components/search.react.js b/web/components/search.react.js
--- a/web/components/search.react.js
+++ b/web/components/search.react.js
@@ -3,6 +3,7 @@
import * as React from 'react';
import SWMansionIcon from 'lib/components/SWMansionIcon.react.js';
+import type { ReactRefSetter } from 'lib/types/react-types.js';
import ClearSearchButton from './clear-search-button.react.js';
import css from './search.css';
@@ -15,7 +16,10 @@
+onClearText?: () => mixed,
};
-function Search(props: Props, ref): React.Node {
+function Search(
+ props: Props,
+ ref: ReactRefSetter<HTMLInputElement>,
+): React.Node {
const { searchText, onChangeText, placeholder, onClearText, ...rest } = props;
const showClearButton = !!searchText;
diff --git a/web/modals/input.react.js b/web/modals/input.react.js
--- a/web/modals/input.react.js
+++ b/web/modals/input.react.js
@@ -3,6 +3,8 @@
import classNames from 'classnames';
import * as React from 'react';
+import type { ReactRefSetter } from 'lib/types/react-types.js';
+
import css from './input.css';
export type BaseInputProps = {
@@ -22,7 +24,10 @@
+maxLength?: number,
};
-function Input(props: InputProps, ref): React.Node {
+function Input(
+ props: InputProps,
+ ref: ReactRefSetter<HTMLInputElement>,
+): React.Node {
const {
label: labelProp,
disabled = false,

File Metadata

Mime Type
text/plain
Expires
Wed, Nov 27, 4:43 AM (10 h, 51 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2580860
Default Alt Text
D9769.id33824.diff (2 KB)

Event Timeline