Skip to content

Commit 10e1dc4

Browse files
committed
Replace useRef<T | null> with useRef<T>
See DefinitelyTyped/DefinitelyTyped#38228 (comment)
1 parent 24b5132 commit 10e1dc4

File tree

9 files changed

+17
-17
lines changed

9 files changed

+17
-17
lines changed

examples/HTML5ConstraintValidationAPI/App.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ function hasErrors(errors: Errors) {
2929
}
3030

3131
function Form() {
32-
const email = useRef<HTMLInputElement | null>(null);
33-
const password = useRef<HTMLInputElement | null>(null);
34-
const passwordConfirm = useRef<HTMLInputElement | null>(null);
32+
const email = useRef<HTMLInputElement>(null);
33+
const password = useRef<HTMLInputElement>(null);
34+
const passwordConfirm = useRef<HTMLInputElement>(null);
3535

3636
const [errors, setErrors] = useState<Errors>({
3737
email: [],

examples/MaterialUI/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ function getInitialInputsState() {
6565
}
6666

6767
function Form({ classes }: FormProps) {
68-
const form = useRef<FormWithConstraints | null>(null);
69-
const password = useRef<HTMLInputElement | null>(null);
68+
const form = useRef<FormWithConstraints>(null);
69+
const password = useRef<HTMLInputElement>(null);
7070

7171
const [inputs, setInputs] = useState<InputsState>(getInitialInputsState());
7272
const [signUpButtonDisabled, setSignUpButtonDisabled] = useState(false);

examples/Password/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ async function isACommonPassword(password: string) {
3939
}
4040

4141
function Form() {
42-
const form = useRef<FormWithConstraints | null>(null);
43-
const password = useRef<HTMLInputElement | null>(null);
42+
const form = useRef<FormWithConstraints>(null);
43+
const password = useRef<HTMLInputElement>(null);
4444

4545
const [inputs, setInputs] = useState({
4646
email: '',

examples/PasswordWithoutState/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import './index.html';
66
import './style.css';
77

88
function Form() {
9-
const form = useRef<FormWithConstraints | null>(null);
10-
const password = useRef<HTMLInputElement | null>(null);
9+
const form = useRef<FormWithConstraints>(null);
10+
const password = useRef<HTMLInputElement>(null);
1111

1212
async function handleChange({ target }: React.ChangeEvent<HTMLInputElement>) {
1313
await form.current!.validateFields(target);

examples/PlainOldReact/App.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ function hasErrors(errors: Errors) {
3939
}
4040

4141
function Form() {
42-
const email = useRef<HTMLInputElement | null>(null);
43-
const password = useRef<HTMLInputElement | null>(null);
44-
const passwordConfirm = useRef<HTMLInputElement | null>(null);
42+
const email = useRef<HTMLInputElement>(null);
43+
const password = useRef<HTMLInputElement>(null);
44+
const passwordConfirm = useRef<HTMLInputElement>(null);
4545

4646
const [errors, setErrors] = useState<Errors>({
4747
email: [],

examples/ServerSideRendering/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ async function isACommonPassword(password: string) {
3737
}
3838

3939
function Form() {
40-
const form = useRef<FormWithConstraints | null>(null);
41-
const password = useRef<HTMLInputElement | null>(null);
40+
const form = useRef<FormWithConstraints>(null);
41+
const password = useRef<HTMLInputElement>(null);
4242

4343
const [inputs, setInputs] = useState({
4444
email: '',

examples/WizardForm/WizardFormStep1.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ interface Props {
99
}
1010

1111
export function WizardFormStep1(props: Props) {
12-
const form = useRef<FormWithConstraints | null>(null);
12+
const form = useRef<FormWithConstraints>(null);
1313

1414
async function handleChange({ target }: React.ChangeEvent<HTMLInputElement>) {
1515
props.onChange(target);

examples/WizardForm/WizardFormStep2.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ interface Props {
1212
}
1313

1414
export function WizardFormStep2(props: Props) {
15-
const form = useRef<FormWithConstraints | null>(null);
15+
const form = useRef<FormWithConstraints>(null);
1616

1717
async function handleChange({ target }: React.ChangeEvent<HTMLInputElement>) {
1818
props.onChange(target);

examples/WizardForm/WizardFormStep3.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ interface Props {
1313
}
1414

1515
export function WizardFormStep3(props: Props) {
16-
const form = useRef<FormWithConstraints | null>(null);
16+
const form = useRef<FormWithConstraints>(null);
1717

1818
async function handleChange({
1919
target

0 commit comments

Comments
 (0)