Ensures that the given value is not null or undefined.
function Component() { const ref = useRef<HTMLSpanElement>(null); function onClick() { const span = ref.current; assertDefinedNotNull(span); span.textContent = 'Hello world!'; } return ( <div> <button onClick={onClick}>Click me</button> <span ref={ref}></span> </div> )} Copy
function Component() { const ref = useRef<HTMLSpanElement>(null); function onClick() { const span = ref.current; assertDefinedNotNull(span); span.textContent = 'Hello world!'; } return ( <div> <button onClick={onClick}>Click me</button> <span ref={ref}></span> </div> )}
Ensures that the given value is not null or undefined.