title: React TextInput reference in typescript
body: <p>In typescript, I have <code>const searchField = React.useRef&lt;TextInput&gt;(null)</code>;</p>
  <p><code>searchField.current.focus();</code> rightfully complains that <code>Object is possibly 'null'</code> - fine! So I write <code>searchField.current?.focus();</code> where the <code>?</code> is supposed to act as a if operator of sort, right?</p>
  <p>So if I get it correctly, it's basically saying &quot;if I have a <code>searchField.current</code> then do something, otherwise not&quot;, in which case it still complains with <code>Expected an assignment or function call and instead saw an expression</code>.</p>
  <p>If I write the if statement below, it stops complaining:</p>
  <pre><code>if (searchField.current) {
    searchField.current.focus();
  }
  </code></pre>
  <p>But isn't it the same as <code>searchField.current?.focus();</code>? What am I missing?</p>