I've recently ran into this TSX syntax:
<SomeElement
onClick={() => {
setSearchInput('')
ref.current!!.focus()
}}
/>
SomeElement
has a type of React.ForwardRefExoticComponent<SomeInterface & React.RefAttributes<HTMLInputElement>>
ref.current
has a type of
React.MutableRefObject<HTMLInputElement>.current: HTMLInputElement | null
Could anyone explain what's up with the double bang (!!
) before .focus()
? According to linter, it is valid syntax.
Where is this documented? I've searched MDN for the list of operators and I haven't found anything relevant.
I know what a double negation is (e.g: replacement for Boolean()
), but this doesn't seem to be the case. Or... is it?