From 9349ebd37ab70e3d8f7f619f7ae793de8703a498 Mon Sep 17 00:00:00 2001 From: Vincent Date: Tue, 31 Mar 2020 17:56:23 +1100 Subject: [PATCH] fancy syntax --- ts/components/session/SessionPasswordModal.tsx | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/ts/components/session/SessionPasswordModal.tsx b/ts/components/session/SessionPasswordModal.tsx index 4d7091057..441196314 100644 --- a/ts/components/session/SessionPasswordModal.tsx +++ b/ts/components/session/SessionPasswordModal.tsx @@ -44,11 +44,7 @@ export class SessionPasswordModal extends React.Component { public componentDidMount() { setTimeout(() => { - if (!this.passwordInput.current) { - return; - } - - this.passwordInput.current.focus(); + this.passwordInput.current?.focus(); }, 100); } @@ -140,14 +136,10 @@ export class SessionPasswordModal extends React.Component { } private async setPassword(onSuccess: any) { - if (!this.passwordInput.current || !this.passwordInputConfirm.current) { - return; - } - // Trim leading / trailing whitespace for UX - const enteredPassword = String(this.passwordInput.current.value).trim(); + const enteredPassword = String(this.passwordInput.current?.value).trim(); const enteredPasswordConfirm = String( - this.passwordInputConfirm.current.value + this.passwordInputConfirm.current?.value ).trim(); if (enteredPassword.length === 0 || enteredPasswordConfirm.length === 0) {