Closed
Description
What cheatsheet is this about? (if applicable)
Basic cheatsheet
What's your issue or idea?
According to the documentation useRef Hook has two options.
const ref1 = useRef<HTMLElement>(null!);
const ref2 = useRef<HTMLElement | null>(null);
The first option will make ref1.current
read-only. But after trying out some examples I feel there are some issues. As it shows MutableRefObject for the first option. So ref1.current
is not read-only.
I am exploring TypeScript with React so maybe I am missing something. Can someone please help me with this?
(If applicable) Reproduction of issue in TypeScript Playground